View Full Version : Lisp to move block along line
jayhay35365091
2013-09-12, 07:08 PM
Is it possible to write a lisp routine that will allow you to move a schematic symbol that is on a line and keep the line attached on both ends? Similar to the scoot command in AutoCAD electrical.
EX:
---p--- to -p---- or -----p-
Tharwat
2013-09-12, 08:12 PM
I guess the STRETCH command could help in this regard but keep in mind that the stretch command needs to select objects by window selection set with one shut otherwise the result won't be as expected .
jayhay35365091
2013-09-12, 09:29 PM
Stretch works but I'm looking for a way to only select the block and be able to scoot it around.
Tharwat
2013-09-13, 07:32 AM
I am not using Autocad Electrical so I don't know the scoot command in that version , so can you bring a snapshot or a sample drawing showing your aim of the routine ?
Did you try to wipeout the background of the block and after that you won't be in need of the two end points of lines , but you need complete lines .
cadplayer
2013-09-13, 08:37 AM
I have no Autocad electrical, but this routine can move a block along a Polyline. My problem only is, how I can stop grread if I would stop moving. Now it stops only with push esc.
(defun c:foo ( / myerror pline block z pt)
(setq oldError *error*)
(defun myError (msg)
(setvar "OSMODE" osm)
(princ (strcat "\nCancel: " msg))
(setq *error* oldError)
)
(setq osm (getvar "OSMODE"))
(setvar "OSMODE" 0)
(setq *error* MyError)
(setq z 0)
(while (not (and (<= z 0)
(setq obj (entsel "\n Select a Polyline"))
(= "LWPOLYLINE" (cdr (assoc 0 (entget (setq pline (car obj))))))
(while (not (and (>= z 0)
(setq obj (entsel "\n Select a Block"))
(if (= "INSERT" (cdr (assoc 0 (entget (setq block (car obj))))))
(setq z 1)
)
)
)
z
)
)
)
(setq pt (cadr (grread t 13)))
(while
(= 5 (car (setq pt (grread t 13 0))))
(redraw)
(setq pt (cadr pt)
cp (vlax-curve-getclosestpointto pline pt)
)
(grdraw pt cp 1 1)
(entmod (subst (cons 10 (mapcar '+ cp (list 0 0))) (assoc 10 (entget block)) (entget block)))
)
(redraw)
)
(setq *error* oldError )
(setvar "OSMODE" osm)
(princ)
)
jayhay35365091
2013-09-13, 06:01 PM
Seems to be closer to what I'm needing but still having problems getting it to run correctly.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.