Arc Length lisp

Arc Length lisp

heather_o
Enthusiast Enthusiast
3,037 Views
10 Replies
Message 1 of 11

Arc Length lisp

heather_o
Enthusiast
Enthusiast

I am very basic when it comes to lisp routines.  I know very little and don't really understand when I see code in messages.  

I have a lisp that will add the length of lines with or without the bearings, which is great!  I use it all the time.  But it doesn't add the length of the arcs.  So I'm looking for a lisp that will add the length in simple text form (xx.xx)

I've looked through many posts and found this (attached) but it didn't work.  I'm hoping you guys, with all your wisdom, can help me.

(defun c:CA ( / ss acadModel precision ctr obj len rad ang txt txtObj)
  
(if (setq ss (ssget '((0 . "ARC"))))
(progn

(setq acadModel (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))))
(setq precision 2)

(setq ctr 0)
(repeat (sslength ss)

(setq obj (vlax-ename->vla-object (ssname ss ctr)))
(setq len (rtos (vla-get-arcLength obj) 2 precision))
(setq rad (rtos (vla-get-radius obj) 2 precision))
(setq ang (rtos (cvunit (vla-get-totalAngle obj) "radians" "degrees") 2 precision))

(setq txt (strcat "L=" len " R=" rad " A=" ang))
(setq txtObj (vla-addtext acadModel txt (vla-get-center obj) 1))
(vla-put-alignment txtObj acAlignmentMiddleCenter)
(vla-put-textAlignmentPoint txtObj (vla-get-center obj))
);repeat

));if ss
(princ)
);defun
0 Likes
Accepted solutions (1)
3,038 Views
10 Replies
Replies (10)
Message 2 of 11

Kent1Cooper
Consultant
Consultant

There are numerous routines out there for adding up the total length of multiple objects, for example >this<.  Is something like that sufficient?  If you want just Arcs, instead of possibly multiple object types, it can probably be adjusted [I haven't opened it to see how it works].

 

And if a less-universal routine is desired, what kind of return are you after?  A Text or Mtext object in the drawing?  Just a notification at the Command line?  An alert box?  Something else?

Kent Cooper, AIA
0 Likes
Message 3 of 11

heather_o
Enthusiast
Enthusiast

Thanks for the quick reply!

 

I found one of your lisp routines, Kent.    DimArcLengthRadAngle.LSP

I just need it to add simple text (dtext) above or below the arc to the precision of xx.xx

I work with plats and need it to find the length and add it by the arc.  

I use this one for lines, but it doesn't query the arc lengths.

0 Likes
Message 4 of 11

Kent1Cooper
Consultant
Consultant

Though it doesn't do your totaling, at least to make the routine in Message 1 work as it's probably intended to [i.e. to put the label in for every Arc in the selection], it needs a line added:

 

....

    (vla-put-textAlignmentPoint txtObj (vla-get-center obj))
    (setq ctr (1+ ctr))
  );repeat

....

Kent Cooper, AIA
0 Likes
Message 5 of 11

heather_o
Enthusiast
Enthusiast

where do I add that line at?

0 Likes
Message 6 of 11

heather_o
Enthusiast
Enthusiast

nevermind

0 Likes
Message 7 of 11

heather_o
Enthusiast
Enthusiast

I added the line and it still doesn't work.  I click on the arc and nothing happens

0 Likes
Message 8 of 11

heather_o
Enthusiast
Enthusiast

sorry for all the replies.  It did work, the text was far enough from the arc that I didn't see it at first

0 Likes
Message 9 of 11

Kent1Cooper
Consultant
Consultant
Accepted solution

@heather_o wrote:

....

I just need it to add simple text (dtext) above or below the arc to the precision of xx.xx

....


So by "add the length" in Message 1 you don't mean [as I assumed originally, hence the link] to add up the total of the lengths of multiple Arcs, but to "add" Text to the drawing showing the length of each individual Arc.

 

You can use the DIMARC command.  Make a Dimension Style with these settings:

Kent1Cooper_1-1616680651686.png

 

Kent1Cooper_0-1616680607115.png

 

Kent1Cooper_2-1616680717203.png

 

and whatever is appropriate in the way of Text Style, height, etc.

 

That has the big advantage that if you change the Arc, it updates, though you will often want to reposition the text.

 

Kent Cooper, AIA
0 Likes
Message 10 of 11

Kent1Cooper
Consultant
Consultant

@heather_o wrote:

sorry for all the replies.  It did work, the text was far enough from the arc that I didn't see it at first


[Yes, that one puts it at the center of the Arc, which at a large radius can be pretty far away.]

Kent Cooper, AIA
0 Likes
Message 11 of 11

heather_o
Enthusiast
Enthusiast

dimarc will work!  Thank you so so much

0 Likes