Anuncios

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Need Lisp, to add Vortex on Arc every 0.1m

Anonymous

Need Lisp, to add Vortex on Arc every 0.1m

Anonymous
No aplicable

Hi Friends,

 

I need Lisp on multiple Arc's, to add vortex on ever 0.1m on drawing and finally conver that's all Arc into Line property.

(Many Arc's in Drawing) difficult to select and process one by one.

I will be appropriate if someone help me on this Issue...

Thanks in advance for cooperation and Support.

Regards,

Surya.

 

 

 

0 Me gusta
Responder
486 Vistas
3 Respuestas
Respuestas (3)

3wood
Advisor
Advisor

There are some detailed questions to consider, for example if the length of arc is not  exactly divided by 0.1m, there is  a shorter part at one end. How do you deal with such situation?

Capture.PNG

0 Me gusta

Kent1Cooper
Consultant
Consultant

If the answer to @3wood's question is that you would want all line segments the same length, which should not be more than 0.1 drawing units, but may be slightly shorter to divide equally and prevent a much-shorter one at the end, try this:

 

(defun C:A2PL ; = Arc(s) {to} Polylines of all Line segments
  (/ maxseg ss n arc len segs seglen inc)
  (setq maxseg (getdist "\nMaximum segment length: "))
  (prompt "\nTo convert Arc(s) to Polyline(s) of Line segments,")
  (if (setq ss (ssget "_:L" '((0 . "ARC"))))
    (repeat (setq n (sslength ss))
      (setq
        arc (ssname ss (setq n (1- n)))
        len (getpropertyvalue arc "length")
        segs (/ len maxseg)
        segs (+ (fix segs) (if (equal (rem len maxseg) 0 1e-4) 0 1))
        seglen (/ len segs)
        inc 0
      ); setq
      (command "_.pline" "_non" (vlax-curve-getStartPoint arc) "_width" 0 0)
      (repeat segs
        (command "_non" (vlax-curve-getPointAtDist arc (* seglen (setq inc (1+ inc)))))
      ); repeat
      (command "")
      (entdel arc)
    ); repeat
  ); if
  (princ)
); defun
(vl-load-com)

 

It could have the 0.1 unit maximum segment length built in, rather than ask for it, if you always use the same.  And it could have the other usual enhancements, but first see whether it does what you want.

Kent Cooper, AIA

Kent1Cooper
Consultant
Consultant

If, on the other hand, you want results as in @3wood 's image, with whatever shorter-length piece is left over at one end, this will do that:

 

(defun C:A2PL ; = Arc(s) {to} Polylines of all Line segments
  (/ seglen ss n arc len segs inc)
  (setq seglen (getdist "\nSegment length: "))
  (prompt "\nTo convert Arc(s) to Polyline(s) of Line segments,")
  (if (setq ss (ssget "_:L" '((0 . "ARC"))))
    (repeat (setq n (sslength ss))
      (setq
        arc (ssname ss (setq n (1- n)))
        len (getpropertyvalue arc "length")
        segs (/ len seglen)
        segs (+ (fix segs) (if (equal (rem len maxseg) 0 1e-4) 0 1))
        inc 0
      ); setq
      (command "_.pline" "_non" (vlax-curve-getStartPoint arc) "_width" 0 0)
      (repeat (1- segs)
        (command "_non" (vlax-curve-getPointAtDist arc (* seglen (setq inc (1+ inc)))))
      ); repeat
      (command (vlax-curve-getEndPoint arc) "")
      (entdel arc)
    ); repeat
  ); if
  (princ)
); defun
(vl-load-com)

 

But bear in mind that it measures the specified distance between vertices along the curve of the Arc, which means that the resulting Polyline line segments are chords and therefore slightly shorter [how much shorter depends on the radius of the Arc] -- here with a specified distance of 1 drawing unit:

Kent1Cooper_0-1626783167554.png

If it's important for the line segments to be exactly the specified length, that could be calculated based on the radius.

Kent Cooper, AIA