Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Divide aec line segments into equal no of segments

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
685 Views, 2 Replies

Divide aec line segments into equal no of segments

Dear All,

I want to select no of lines & arcs

And then want to dicide them equally if I give the number say 100

so that 100 equal segments will be done for these segments

 

Kindly give me solution for above.

- Sanjay

 

Currently I am doing as below

 

 

(defun segments()
  (setq secs
    ;(if (numberp _sdsec_)
     ; _sdsec_ ; then
      (if (zerop (rem entlen _sdmax_)); else
        (fix (/ entlen _sdmax_))
        (1+ (fix (/ entlen _sdmax_)))
      ); end if and else
    ;); end if
    seclen (/ entlen secs)
         
  ); end setq
);segments
 

  ;;;;;;;drawarc

  (defun DrawArc
     (data numSeg / arcobj stpoint edpoint arad entlen seglen)
     (setq arcobj (vlax-ename->vla-object data))
     (setq stpoint (vlax-curve-getstartpoint arcobj)
           edpoint (vlax-curve-getendpoint arcobj)
           arad (vlax-get-property arcobj 'Radius)
           entlen (vlax-get-property arcobj 'arcLength)
           seglen (/ entlen numSeg)
     )

      (segments)           
                 (if (= _sdmax_ seclen)  
                 (setq seclen (- seclen 0.00001)))
                 (subdiv ent (1- secs))
    
  );DrawArc

 

 

 

(setq ssall(ssget))

 

 

 

 (defun main1()
  (if ssall
    (progn
      (setq numentall (sslength ssall)
     counta   0)
  (while (> numentall counta)
 
  (setq entall (ssname ssall counta)
       entdata (entget entall))
 
  (setq ss1(ssadd))
    (ssadd entall ss1)
  (if ss1
    (progn
      (setq numents (sslength ss1)
        count   0)
         (setq ent (ssname ss1 count)
               entdata (entget ent))
        (cond
           ((= (cdr (assoc 0 entdata)) "ARC")
            
            (if (= a1 "BP")
                (setq _sdmax_ seclen1)
                   )
            
             (DrawArc ent 1)
        
            
           ))

         (cond
           ((= (cdr (assoc 0 entdata)) "LINE")
            
                (if (= a1 "BP")
                (setq _sdmax_ seclen1)
                   )
            
          (setq entlen (vlax-curve-getDistAtParam ent (vlax-curve-getEndParam ent)))
        
            
                (segments)
                (if (= _sdmax_ seclen)  
                (setq seclen (- seclen 0.00001)))
            (subdiv ent (1- secs))
           ))
     )
    )
      
    
       (setq segcount (+ segcount secs))

        (setq counta (1+ counta))

     );while end
    )
   )
);end main1

2 REPLIES 2
Message 2 of 3
Kent1Cooper
in reply to: Anonymous


@Anonymous wrote:

.... I want to select no of lines & arcs

And then want to dicide them equally if I give the number say 100

so that 100 equal segments will be done for these segments

....


Try this out.  It works on Lines, Arcs, Circles, Polylines, Ellipses, and Splines, open or closed.  And it has some interesting options -- see comments at the top of the file.

Kent Cooper, AIA
Message 3 of 3
Anonymous
in reply to: Kent1Cooper

Kent thanks for your reply,

I used your programme

but it has one problem

when you pass no of segments say 100 to second polyline it gives me correct segments of 100 polylines

but when I explode it turns into line and arcs and this time number gets adds up , it goes to 102 or 103

I want eaxct no of arcs & lines for both the polylines.

 

I want a simple programme where it will capture as below

 1) I have polyline contaiing arcs lines I first explode it

2) programme should pick these arcs & lines

3) it will ask for segment length say (0.3)

3) then it will create no of segments say 100

 

4)  I have another polyline contaiing arcs lines I will explode it

5) then this no 100 I will pass to another arcs  & lines 

    so  it will pick these arcs & lines 

6) programme should create exact 100 segments

 

Attached programme for your ref.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost