Applying Geometric constrains with Lisp

Applying Geometric constrains with Lisp

Anonymous
Not applicable
1,409 Views
5 Replies
Message 1 of 6

Applying Geometric constrains with Lisp

Anonymous
Not applicable

Good day friends !!


Is there a way to apply geometric constrains with lisp? I have a number of polylies that connect to a block at certain points via a lisp rutine. what I need is to have the end point of the poly line (which is connected to the block) move with the block when the block is moved !! like in facy electrical softwares !  I want the end popint of the PL to coinciede with a point in a block using geomconstrains commands ! I hope my explainations suffice ?!

I have tried to provide the "GcCoincident" command with an end point of an entiry as follows but with no success:

 

(setq pt (getpoint "\nSelect end point on the object: "))

(setq pt-ent1 (nentselp (osnap pt "end")))

(command "GcCoincident" pt-ent1 ....

 

I get this error:

Invalid selection for Coincident. Select a line, polyline segment, circle, arc,
ellipse or spline.

 

Also If you reckon it cannot be done at all with blocks, I'd appreciate it if someone could provide me with a sample code that does a coincident constrain between any two objects !!

 

Thank you very much.

 

K.m

0 Likes
Accepted solutions (1)
1,410 Views
5 Replies
Replies (5)
Message 2 of 6

john.uhden
Mentor
Mentor
Sounds like a need for a reactor so if the block moves, then the polyline vertex goes with it. I'm from the olden days so I am not familiar with the GcCoincident command.

John F. Uhden

0 Likes
Message 3 of 6

steve_carson
Enthusiast
Enthusiast
Accepted solution

I think your error is related to the return value of the nentselp function, because after trying out your code, the pt-ent1 variable contained an entity name and a point.

 

However, using the pt variable worked fine:

 

(command "GcCoincident" pt pause)

 

I put the pause in there for the user to select the point on the block.

 

 

HTH

 

Steve

Message 4 of 6

Ranjit_Singh
Advisor
Advisor

You said several plines are connected and then you say a PL should move. Can you post a sample drawing showing the block, all the lines that connect to it and just call out a leader on the drawing stating the intent (which line(s) should move to which point(s) and so forth). I think it will be easier to understand.

0 Likes
Message 5 of 6

Anonymous
Not applicable

Steve you magnificent genius !  😉

well you are absolutely correct ! the thing is that I was using the coordinates I got form the insertion point of a block (which happen to have a point or node on it) to use as the start point of the poly-line. now you can see that after the code draws the poly-line, the start point of the poly-line and the insertion point of the block are on top of each other and makes them hard to pick !! that's why i somehow wanted the entity name to be passed along with the point !! am I making any sense at all ?! 

now I could swear that the syntax you used was not working when i tried it with the points that I passed along to it using the code (not picking them my self using getpoint) !!! 

 

what I ended up using, thanks to you Steve, is this:

 

 

(SETQ PP1 (CAR (CDR (SETQ PT1 (NENTSELP (OSNAP P1 "END"))))))       ;;; picks the end point on the poly-line at location p1 

(SETQ PP2 (CAR (CDR (SETQ PT1 (NENTSELP (OSNAP P1 "NODE"))))))      ;;; picks the node on the block (at insertion point) at location p1 

(command "GcCoincident" PP1 PP2)     ;;; makes the the poly-line and the block fixed together !! Yeay !!

 

Thank you very much you guys 😉

I hope this helps some other rookie developers that are stuck !!

 

Cheers

 

0 Likes
Message 6 of 6

steve_carson
Enthusiast
Enthusiast

You're very welcome, happy to help. 🙂

0 Likes