kylesom Posted April 4, 2011 Posted April 4, 2011 Hi all. I've tried pulling together an autolisp for a repetitive procedure that is about to bug our office but I just don't have the know how at this stage to make it work. We basically need to use the "measure" command to insert a block on (many) multiple polylines at regular 20m intervals. Can someone advise or give sample code that would do this? Basically select the measure command, allow me to select the polyline (or select multiple polylines, that would be even better!), select the Block option, enter block name (call it Block1 for now), confirm Y for alignment with the polyline, and then auto specify 20m intervals. Any / all help appreciated! Quote
Tharwat Posted April 4, 2011 Posted April 4, 2011 Check this out Buddy . (defun c:TesT (/ blk ss l name) ; TharwaT 04. 04. 2011 (if (and (setq blk (entsel "\n Select Block :")) (setq ss (ssget "_:L" '((0 . "LINE,SPLINE,LWPOLYLINE,POLYLINE")))) (setq l (getdist "\n Distance between Blocks :")) ) (progn (setq name (cdr (assoc 2 (entget (car blk))))) ((lambda (i / ss1) (while (setq ss1 (ssname ss (setq i (1+ i)))) (command "_.measure" ss1 "Block" name "_Y" l) ) ) -1 ) ) (princ) ) (princ) ) TharwaT Quote
stevesfr Posted April 4, 2011 Posted April 4, 2011 Check this out Buddy . (defun c:TesT (/ blk ss l name) ; TharwaT 04. 04. 2011 (if (and (setq blk (entsel "\n Select Block :")) (setq ss (ssget "_:L" '((0 . "LINE,SPLINE,LWPOLYLINE,POLYLINE")))) (setq l (getdist "\n Distance between Blocks :")) ) (progn (setq name (cdr (assoc 2 (entget (car blk))))) ((lambda (i / ss1) (while (setq ss1 (ssname ss (setq i (1+ i)))) (command "_.measure" ss1 "Block" name "_Y" l) ) ) -1 ) ) (princ) ) (princ) ) TharwaT This is great ! How can I make modification to change the scale of selected block as it is being inserted ? thanks, Steveo Quote
Tharwat Posted April 4, 2011 Posted April 4, 2011 This is great ! How can I make modification to change the scale of selected block as it is being inserted ?thanks, Steveo Thank you . I guess you can not scale the block that going to be distributed along the selected line because the command measure would insert the block by its name and not as selected object . May be someone else could bring something against this truth . TharwaT Quote
alanjt Posted April 4, 2011 Posted April 4, 2011 You would need to roll your own with vlax-curve-getPointAtDist (see my CopyAlongCurve.LSP) or store the last entity (entlast) before you measure each object, then, after curve has been measured, use entnext to select each newly created object (block) and rescale, based on scale properties of originally selected block. Quote
fixo Posted April 4, 2011 Posted April 4, 2011 Steve Try this slightly edited code (defun c:TesT2 (/ blk ss l name) ; TharwaT 04. 04. 2011 (if (and (setq blk (entsel "\n Select Block :")) (setq ss (ssget "_:L" '((0 . "LINE,SPLINE,LWPOLYLINE,POLYLINE")))) (setq l (getdist "\n Distance between Blocks :")) (setq scl (getdist "\n Enter a scale :")) ) (progn (setq name (cdr (assoc 2 (entget (car blk))))) ((lambda (i / ss1) (while (setq ss1 (ssname ss (setq i (1+ i)))) (setq marker(entlast)) (command "_.measure" ss1 "Block" name "_Y" l) (while (setq en (entnext marker)) (setq elist (entget en) pt (cdr (assoc 10 elist))) (command "_scale" en "" "_non" pt scl) (princ (cdr (assoc 2 elist))) (entupd en) (setq marker en) ) ) ) -1 ) ) (princ) ) (princ) ) ~'J'~ Quote
stevesfr Posted April 4, 2011 Posted April 4, 2011 SteveTry this slightly edited code (defun c:TesT2 (/ blk ss l name) ; TharwaT 04. 04. 2011 (if (and (setq blk (entsel "\n Select Block :")) (setq ss (ssget "_:L" '((0 . "LINE,SPLINE,LWPOLYLINE,POLYLINE")))) (setq l (getdist "\n Distance between Blocks :")) (setq scl (getdist "\n Enter a scale :")) ) (progn (setq name (cdr (assoc 2 (entget (car blk))))) ((lambda (i / ss1) (while (setq ss1 (ssname ss (setq i (1+ i)))) (setq marker(entlast)) (command "_.measure" ss1 "Block" name "_Y" l) (while (setq en (entnext marker)) (setq elist (entget en) pt (cdr (assoc 10 elist))) (command "_scale" en "" "_non" pt scl) (princ (cdr (assoc 2 elist))) (entupd en) (setq marker en) ) ) ) -1 ) ) (princ) ) (princ) ) ~'J'~ fixo !!! you did it !! thanks, Steve Quote
fixo Posted April 4, 2011 Posted April 4, 2011 Steve, You're welcome But thanks to Tharwat Cheers, friend Oleg Quote
ajazraj Posted July 1, 2013 Posted July 1, 2013 how can i use the above lisp for varrying spacing between to blocks... Quote
neophoible Posted July 1, 2013 Posted July 1, 2013 how can i use the above lisp for varrying spacing between to blocks...The MEASURE command does equal spacing. Did you want UNequal spacing? If so, MEASURE is not the way to go. How much varying do you need? It would be better to show a clear example by uploading a drawing with a pline with several blocks correctly placed along it. Quote
ajazraj Posted July 5, 2013 Posted July 5, 2013 The MEASURE command does equal spacing. Did you want UNequal spacing? If so, MEASURE is not the way to go. How much varying do you need? It would be better to show a clear example by uploading a drawing with a pline with several blocks correctly placed along it. sorry for the late reply.... i have attached a sample dwg. herewith.., now the thing is... i have a horizontal alignment of a metro rail... and i need to place a piers along it , which has non-uniform spacing. suppose if i have data in excel with pier spacing and numbers, can i link excel sheet with any lisp so that it can then be updated afterwards if needed. trial.dwg Quote
ajazraj Posted July 6, 2013 Posted July 6, 2013 SteveTry this slightly edited code (defun c:TesT2 (/ blk ss l name) ; TharwaT 04. 04. 2011 (if (and (setq blk (entsel "\n Select Block :")) (setq ss (ssget "_:L" '((0 . "LINE,SPLINE,LWPOLYLINE,POLYLINE")))) (setq l (getdist "\n Distance between Blocks :")) (setq scl (getdist "\n Enter a scale :")) ) (progn (setq name (cdr (assoc 2 (entget (car blk))))) ((lambda (i / ss1) (while (setq ss1 (ssname ss (setq i (1+ i)))) (setq marker(entlast)) (command "_.measure" ss1 "Block" name "_Y" l) (while (setq en (entnext marker)) (setq elist (entget en) pt (cdr (assoc 10 elist))) (command "_scale" en "" "_non" pt scl) (princ (cdr (assoc 2 elist))) (entupd en) (setq marker en) ) ) ) -1 ) ) (princ) ) (princ) ) ~'J'~ fixo, can u tell me how can i use the above lisp for unequal spacing between blocks? Quote
neophoible Posted July 6, 2013 Posted July 6, 2013 fixo, can u tell me how can i use the above lisp for unequal spacing between blocks?ajazraj, like I tried to explain earlier, this uses the MEASURE command, which uses equal spacing, thus this sort of code will not work for your case. I did not open your DWG because I'm limited to 2012 and below, but your idea of using a spreadsheet to place items along a horizontal line should be doable, if one of the experts here is game. What kind of updating were you hoping for? It might be simpler to just erase and redo the entire thing if there are changes. Quote
alanjt Posted July 6, 2013 Posted July 6, 2013 http://www.cadtutor.net/forum/showthread.php?46309-CopyAlongCurve.LSP-Divide-Measure-Dynamic&highlight=copyalongcurve Quote
ajazraj Posted July 8, 2013 Posted July 8, 2013 ajazraj, like I tried to explain earlier, this uses the MEASURE command, which uses equal spacing, thus this sort of code will not work for your case. I did not open your DWG because I'm limited to 2012 and below, but your idea of using a spreadsheet to place items along a horizontal line should be doable, if one of the experts here is game. What kind of updating were you hoping for? It might be simpler to just erase and redo the entire thing if there are changes. neophoible.... yes, i understand that measure command can not be used. i am attaching dwg. saved in 2007, look at it if possible. LISP suggested by alanjt is quite useful, but still i want to give inputs of spacing through excel. neophoible.... i dnt want to update dwg. as i change the excel, i know that i have to run the lisp again. What i really needed is to give input of spacing through excel. Thank You trial_2007.dwg Quote
ajazraj Posted July 8, 2013 Posted July 8, 2013 http://www.cadtutor.net/forum/showthread.php?46309-CopyAlongCurve.LSP-Divide-Measure-Dynamic&highlight=copyalongcurve Thank You, alanjt ... it is quite useful, but still it is not what i exactly want. Quote
alanjt Posted July 8, 2013 Posted July 8, 2013 Thank You, alanjt ... it is quite useful, but still it is not what i exactly want. The Dynamic option doesn't do what you want? Quote
ajazraj Posted July 8, 2013 Posted July 8, 2013 The Dynamic option doesn't do what you want? I dont have much idea about dynamic blocks. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.