Jump to content

Recommended Posts

Posted (edited)

Hi guys,

 

Does anyone know if there is already a code for getting the radius at the beginning and at the end of an arc by one click. The text should also be placed inside the arc (see (updated) picture).

 

example.jpg

 

If not, can somebody help me please? I'm very poor in programming lisp and I need it really bad.

 

Thx

Edited by woohhoo
  • Replies 41
  • Created
  • Last Reply

Top Posters In This Topic

  • woohhoo

    12

  • alanjt

    9

  • Lee Mac

    7

  • Tharwat

    7

Top Posters In This Topic

Posted Images

Posted

Try this.... :)

 

(defun c:TesT (/ rad p spc acdoc dim1 dim2)
 (vl-load-com)
 ;; Tharwat 22. Nov. 2011 ;;
 (if (and (setq rad (getdist "\n Specify Arc radius :"))
          (setq p (getpoint "\n Specify Center point for arc :"))
     )
   (progn
     (setq spc (if (> (vla-get-activespace
                        (setq acdoc (vla-get-activedocument
                                      (vlax-get-acad-object)
                                    )
                        )
                      )
                      0
                   )
                 (vla-get-modelspace acdoc)
                 (vla-get-paperspace acdoc)
               )
     )
     (vla-StartUndoMark acdoc)
     (vla-addarc spc (vlax-3d-point p) rad 1.11022e-016 1.5708)
     (setq dim1 (vla-adddimradial
                  spc
                  (vlax-3d-point p)
                  (vlax-3d-point (polar p 0. rad))
                  0.
                )
     )
     (vla-put-textposition
       dim1
       (vlax-3d-point (polar p 0. (- rad (/ rad 10.))))
     )
     (setq dim2 (vla-adddimradial
                  spc
                  (vlax-3d-point p)
                  (vlax-3d-point (polar p (/ pi 2.) rad))
                  10.
                )
     )
     (vla-put-textposition
       dim2
       (vlax-3d-point (polar p (/ pi 2.) (- rad (/ rad 10.))))
     )
     (vla-put-rotation dim2 (* pi 1.5))
     (vla-EndUndoMark acdoc)
   )
   (princ)
 )
 (princ)
)

Posted (edited)

??

 

(defun c:Test (/ *error* i ss e d o)

 (vl-load-com)

 (defun *error* (msg)
   (and *AcadDoc* (vla-endundomark *AcadDoc*))
   (if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,")))
     (princ (strcat "\nError: " msg))
   )
 )

 (vla-startundomark
   (cond (*AcadDoc*)
         ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))))
   )
 )

 (if (setq i  -1
           ss (ssget '((0 . "ARC")))
     )
   (while (setq e (ssname ss (setq i (1+ i))))
     (setq d (entget e)
           o (vla-objectidtoobject *AcadDoc* (vla-get-ownerid (vlax-ename->vla-object e)))
     )

     (foreach point (list (polar (cdr (assoc 10 d)) (cdr (assoc 50 d)) (cdr (assoc 40 d)))
                          (polar (cdr (assoc 10 d)) (cdr (assoc 51 d)) (cdr (assoc 40 d)))
                    )
       (vlax-invoke o 'adddimradial (cdr (assoc 10 d)) point -1.)
     )
   )
 )
 (*error* nil)
 (princ)
)

Edited by alanjt
Posted

Hi guys

 

Tharwat, thanks for your input but I tested your code and it works fine but it was a little bit complicated.

The code that Alanjt programmed is almost exactly what I need only there is one little problem. Is it possible that the text always can be placed inside the arc? If you see at the picture, autocad put sometimes (I think depending how the arc is placed) the text (inside the red circle) on the wrong side of the arrowline.

 

example2.jpg

 

Anyway, thx al lot for the input!

 

Grz

Posted

Here is the modified one .....

 

(defun c:TesT (/ ss i sn vl spc acdoc p c l rad p1)
 (vl-load-com)
 ;; Tharwat 23. Nov. 2011 ;;
 (if (setq ss (ssget '((0 . "ARC"))))
   (repeat (setq i (sslength ss))
     (setq sn (ssname ss (setq i (1- i))))
     (setq vl (vlax-ename->vla-object sn))
     (setq spc (if (> (vla-get-activespace
                        (setq acdoc (vla-get-activedocument
                                      (vlax-get-acad-object)
                                    )
                        )
                      )
                      0
                   )
                 (vla-get-modelspace acdoc)
                 (vla-get-paperspace acdoc)
               )
     )
     (vla-StartUndoMark acdoC)
     (vla-adddimradial
       spc
       (vlax-3d-point (setq p (vlax-get vl 'Startpoint)))
       (vlax-3d-point
         (polar p
                (angle p (setq c (vlax-get vl 'Center)))
                (setq l (/ (setq rad (vla-get-radius vl)) 5.))
         )
       )
       0.
     )
     (vla-adddimradial
       spc
       (vlax-3d-point (setq p1 (vlax-get vl 'Endpoint)))
       (vlax-3d-point (polar p1 (angle p1 c) l))
       0.
     )
     (vla-EndUndoMark acdoc)
   )
   (princ)
 )
 (princ)
)

Posted
Hi guys

 

Tharwat, thanks for your input but I tested your code and it works fine but it was a little bit complicated.

The code that Alanjt programmed is almost exactly what I need only there is one little problem. Is it possible that the text always can be placed inside the arc? If you see at the picture, autocad put sometimes (I think depending how the arc is placed) the text (inside the red circle) on the wrong side of the arrowline.

 

[ATTACH=CONFIG]31281[/ATTACH]

 

Anyway, thx al lot for the input!

 

Grz

In your above picture, every dimension is inside it's corresponding arc.
Posted
Here is the modified one .....

You might want to look at your vla-startundomark and vla-endundomark placement. You are executing both for each ename within your selectionset.

Posted

I'll repost to alleviate some sloppiness on my part...

 

(defun c:Test (/ *error* i ss e d o p r)

 (vl-load-com)

 (defun *error* (msg)
   (and *AcadDoc* (vla-endundomark *AcadDoc*))
   (if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,")))
     (princ (strcat "\nError: " msg))
   )
 )

 (vla-startundomark
   (cond (*AcadDoc*)
         ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))))
   )
 )

 (if (setq i  -1
           ss (ssget '((0 . "ARC")))
     )
   (while (setq e (ssname ss (setq i (1+ i))))
     (setq d (entget e)
           o (vla-objectidtoobject *AcadDoc* (vla-get-ownerid (vlax-ename->vla-object e)))
           p (cdr (assoc 10 d))
           r (cdr (assoc 40 d))
     )
     (foreach point (list (polar p (cdr (assoc 50 d)) r) (polar p (cdr (assoc 51 d)) r))
       (vlax-invoke o 'adddimradial p point -1.)
     )
   )
 )
 (*error* nil)
 (princ)
)

Posted (edited)
You might want to look at your vla-startundomark and vla-endundomark placement. You are executing both for each ename within your selectionset.

 

Yeah ... it would step back one by one if the user wanted to go back before the action .

 

Thanks for the hint .:)

 

So here is another modified one for full undo mark to all .

 

(defun c:TesT (/ ss i sn vl spc acdoc p c l rad p1)
 (vl-load-com)
 ;; Tharwat 23. Nov. 2011 ;;
 (if (setq  acdoc (vla-get-activedocument
                         (vlax-get-acad-object)
                       )
            ss
           (ssget '((0 . "ARC")))
     )
   (progn
     (vla-StartUndoMark acdoc)
     (repeat (setq i (sslength ss))
       (setq sn (ssname ss (setq i (1- i))))
       (setq vl (vlax-ename->vla-object sn))
       (setq spc (if (> (vla-get-activespace
                          acdoc
                        )
                        0
                     )
                   (vla-get-modelspace acdoc)
                   (vla-get-paperspace acdoc)
                 )
       )

       (vla-adddimradial
         spc
         (vlax-3d-point (setq p (vlax-get vl 'Startpoint)))
         (vlax-3d-point
           (polar p
                  (angle p (setq c (vlax-get vl 'Center)))
                  (setq l (/ (setq rad (vla-get-radius vl)) 5.))
           )
         )
         0.
       )
       (vla-adddimradial
         spc
         (vlax-3d-point (setq p1 (vlax-get vl 'Endpoint)))
         (vlax-3d-point (polar p1 (angle p1 c) l))
         0.
       )
     )
     (vla-EndUndoMark acdoc)
   )
   (princ)
 )
 (princ)
)

Edited by Tharwat
extra setq
Posted
In your above picture, every dimension is inside it's corresponding arc.

 

yes, the place of the complete dimension (arrow, line and value) is inside its corresponding arc. But the place of the value (e.g. R80,88) is sometimes on the wrong side of the arrowline. The values should be both in the arc-area. It should be like the first picture above.

Posted
Yeah ... it would step back one by one if the user wanted to go back before the action .

 

Thanks for the hint .:)

 

So here is another modified one for full undo mark to all .

 

(defun c:TesT (/ ss i sn vl spc acdoc p c l rad p1)
(vl-load-com)
;; Tharwat 23. Nov. 2011 ;;
(if (setq (setq acdoc (vla-get-activedocument
(vlax-get-acad-object)
)
)
ss
(ssget '((0 . "ARC")))
)
(progn
(vla-StartUndoMark acdoc)
(repeat (setq i (sslength ss))
(setq sn (ssname ss (setq i (1- i))))
(setq vl (vlax-ename->vla-object sn))
(setq spc (if (> (vla-get-activespace
acdoc
)
0
)
(vla-get-modelspace acdoc)
(vla-get-paperspace acdoc)
)
)

(vla-adddimradial
spc
(vlax-3d-point (setq p (vlax-get vl 'Startpoint)))
(vlax-3d-point
(polar p
(angle p (setq c (vlax-get vl 'Center)))
(setq l (/ (setq rad (vla-get-radius vl)) 5.))
)
)
0.
)
(vla-adddimradial
spc
(vlax-3d-point (setq p1 (vlax-get vl 'Endpoint)))
(vlax-3d-point (polar p1 (angle p1 c) l))
0.
)
)
(vla-EndUndoMark acdoc)
)
(princ)
)
(princ)
)

 

It seems that this code doesn't work. I get ; error: syntax error message.

Posted
Yeah ... it would step back one by one if the user wanted to go back before the action .
That's terrible. Suppose, through a series of bad filtering, they select all arcs in the drawing and then want to undo, it would take ages!

 

 

 

yes, the place of the complete dimension (arrow, line and value) is inside its corresponding arc. But the place of the value (e.g. R80,88) is sometimes on the wrong side of the arrowline. The values should be both in the arc-area. It should be like the first picture above.

Could you give me an example when it doesn't operate how you like, rather than showing me what you want and telling me it doesn't work sometimes?

Posted
It seems that this code doesn't work. I get ; error: syntax error message.

Code modified , try again ..:)

Posted
Suppose, through a series of bad filtering, they select all arcs in the drawing and then want to undo, it would take ages!

 

That's right , :thumbsup:

 

Thanks

Posted

@Tharwat, Note that you are retrieving the Active Space over and over for every item in the SelectionSet, this is pretty inefficient, especially for potentially large sets.

Posted
@Tharwat, Note that you are retrieving the Active Space over and over for every item in the SelectionSet, this is pretty inefficient, especially for potentially large sets.

Hey man, he's not shooting for watertight.

Posted
That's terrible. Suppose, through a series of bad filtering, they select all arcs in the drawing and then want to undo, it would take ages!

 

 

 

 

Could you give me an example when it doesn't operate how you like, rather than showing me what you want and telling me it doesn't work sometimes?

 

Ok, I'm gonna try to explain it :cry:

 

1. when I draw an arc and the center of the arc is above the start and endpoint of the arc than the place of dimtext is ok.

2. when I draw another one but the center is under the begin and end point than the place of both dimtext is on the wrong side of the line.

3. When the center of the arc is left or right of the begin and endpoint than one of dimtext is good and the other one is again on the wrong side of the line.

 

I hope this would be helpful.

Posted
@Tharwat, Note that you are retrieving the Active Space over and over for every item in the SelectionSet, this is pretty inefficient, especially for potentially large sets.

 

You're right Lee , and thanks for paying my attention to it , actually Alan rock my world with his first notification to me , while I was about to leave the office which forced me to stay a little bit more to modify the post in a hurry which cause that unforgettable mistake to take a place . :)

 

Hey man, he's not shooting for watertight.

 

On the contrary man , I did expect to see that one day . :lol:

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...