Add limits to lisp routine

Add limits to lisp routine

jtm2020hyo
Collaborator Collaborator
1,872 Views
7 Replies
Message 1 of 8

Add limits to lisp routine

jtm2020hyo
Collaborator
Collaborator

I have a lisp example that work pretty good , this lisp draw between blocks base point, but need add limits as promtp options, first-limit should ignore all blocks under a certain distance and second-limit should of ignore all block over a certain diatance. Leave promtp in blank should be understood like "no limits" for both options. Such "certain distance worth" should be inserted by keyboard or click between 2 points in drawing.

 

Here is the lisp base:

(defun c:connect (/ end fuzz pt ron ss sset)
   (if (and (setq ss (ssget '((0 . "line"))))
            (setq fuzz 0.20)
       )
       (foreach x (setq sset (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))

           (foreach p (list (vlax-curve-getstartpoint x)
                            (vlax-curve-getendpoint x)
                      )
               (foreach y sset
                   (if
                       (and (not (equal (vlax-curve-getclosestpointto y p)
                                        p
                                        1e-11
                                 )
                            )

                            (or (<= (distance (setq pt (vlax-curve-getstartpoint y)) p)
                                    fuzz
                                )
                                (<= (distance (setq pt (vlax-curve-getendpoint y)) p)
                                    fuzz
                                )
                            )
                            (not (equal x y))
                            (> (cadr p) (cadr pt))
                       )
                          (entmod
                              (subst (cons (setq end (if (equal p (vlax-curve-getstartpoint x))
                                                         10
                                                         11
                                                     )
                                           )
                                           pt
                                     )
                                     (assoc end (setq ron (entget x)))
                                     ron
                              )
                          )
                   )
               )
           )
       )
   )
   (princ)
)

Enjoy

0 Likes
Accepted solutions (2)
1,873 Views
7 Replies
Replies (7)
Message 2 of 8

devitg
Advisor
Advisor

Please , upload your DWG 

Message 3 of 8

jtm2020hyo
Collaborator
Collaborator

this image represents how "connect.lsp" work.  ( lisp file attached) (example drawing attached as requested)


the first code posted apparently does not work anymore for me. but i found an updated version that is attached in this reply.
image.png

 

I need to modify this lisp to ignore block under 2 units of proximity (for example and is an alternative) per each line used to link next block and ignore all block over 3 units  of proximity (for example and is an alternative per each line used to link next block , both options should work at the same time per each polyline generated if I need.


 

0 Likes
Message 4 of 8

jtm2020hyo
Collaborator
Collaborator

I attached 3 lisp routines that might help to solve this case.


0 Likes
Message 5 of 8

dbhunia
Advisor
Advisor
Accepted solution

Try this.....

 


@jtm2020hyo wrote:

.........

I need to modify this lisp to ignore block under 2 units of proximity (for example and is an alternative) per each line used to link next block and ignore all block over 3 units  of proximity (for example and is an alternative per each line used to link next block , both options should work at the same time per each polyline generated if I need.


 

This is combination of both options........that is it connect blocks which is within a range (MIN to MAX).......

 

 


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
Message 6 of 8

dbhunia
Advisor
Advisor
Accepted solution

Try this also ........ for all options...... But I did not get the Red Marked point.......

 


@jtm2020hyo wrote:

 

............................

I need to modify this lisp to ignore block under 2 units of proximity (for example and is an alternative) per each line used to link next block and ignore all block over 3 units  of proximity (for example and is an alternative per each line used to link next block , both options should work at the same time per each polyline generated if I need.


 

 


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
Message 7 of 8

jtm2020hyo
Collaborator
Collaborator

@dbhunia wrote:

Try this also ........ for all options...... But I did not get the Red Marked point.......

 


@jtm2020hyo wrote:

 

............................

I need to modify this lisp to ignore block under 2 units of proximity (for example and is an alternative) per each line used to link next block and ignore all block over 3 units  of proximity (for example and is an alternative per each line used to link next block , both options should work at the same time per each polyline generated if I need.


 

 


works perfectly. you are the best. thanks again.

0 Likes
Message 8 of 8

Anonymous
Not applicable

Is there any way to get this lisp to work in a 3D way? For example if I have a lot of points close together and want to create a polyline that limits based on Z value as well as distance?