Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Valued Contributor
tommcgtx
Posts: 66
Registered: ‎01-22-2010
Message 11 of 15 (649 Views)

Re: Insert Block along polyline by distance & offset

05-05-2011 08:07 AM in reply to: siukai10

Kent1Cooper,

 

I tried to add the lines you suggested, but got a "syntax error". I don't know if I entered them in wrong or what, and I am not experienced enough to figure it out. Thank you.

*Expert Elite*
Kent1Cooper
Posts: 5,292
Registered: ‎09-13-2004
Message 12 of 15 (648 Views)

Re: Insert Block along polyline by distance & offset

05-05-2011 08:14 AM in reply to: tommcgtx

tommcgtx wrote:

By "this" I meant the MEA+ and DIV+ from Cadalyst in the post I replied to.


[Actually, those would be referred to by "That works great" in Message 8 -- look back at "This works great" in Message 6, from before I posted the link to DIV+/MEA+.]

 

I just wanted to be sure you were referring to the code in Message 1, not something else on the thread, as a basis for something to add a scaling option to.  I hadn't realized before [not having loaded it up or studied it very deeply] that Message 1 was built to take varying distances, rather than regular spacing -- probably the use of Measure in Message 3 threw me, because I hadn't read Message 5 all the way through to realize that Message 3 isn't operationally equivalent to Message 1.

 

My suggestion in Message 9 would be to add a scale option to the code in Message 1.  It would be considerably more complicated to "fix" DIV+/MEA+ for your purpose, because they are built to enhance the possibilities of ordinary Divide & Measure, but otherwise to be like them.  Consequently, both of them result in regularly-spaced placements.  Altering them to take a sequence of varying distances would be a much bigger re-write than just adding the scale option to Message 1, if it otherwise does what you want.

Kent Cooper
*Expert Elite*
Kent1Cooper
Posts: 5,292
Registered: ‎09-13-2004
Message 13 of 15 (646 Views)

Re: Insert Block along polyline by distance & offset

05-05-2011 08:21 AM in reply to: tommcgtx

tommcgtx wrote:

.... 

I tried to add the lines you suggested, but got a "syntax error". I don't know if I entered them in wrong or what, and I am not experienced enough to figure it out. Thank you.


It could be that you put the scale prompt in some inappropriate place, such as within one of those (while) loops or something.  Post your adjusted version, and it may be apparent.

 

Or it may be that if you include X and Y scale factors in an (entmake) entity-data list, you must also include a Z scale factor -- I haven't tried that.  If that's the problem, this should fix it:

....

      (cons 10 ipt)

      (cons 41 scl); X scale factor
      (cons 42 scl); Y scale factor
      (cons 43 scl); Y scale factor
      (cons 50 ang)

....

Kent Cooper
Valued Contributor
tommcgtx
Posts: 66
Registered: ‎01-22-2010
Message 14 of 15 (642 Views)

Re: Insert Block along polyline by distance & offset

05-05-2011 08:55 AM in reply to: Kent1Cooper

Kent1Cooper,

 

Thank you, I pasted the lines with the Z scale factor, and it works! I don't know if I pasted the lines in the wrong place at first, but here is what I ended up with:

 

(defun C:UT (/ os ce bm blk ent obj ppt dst ept ref len ipt par slp ang)
(command "_.undo" "_be")
(setq os (getvar "osmode")
ce (getvar "cmdecho")
bm (getvar "blipmode")
blk ""
);;setq
(if (not bk)(setq bk ""))
(setvar "osmode" 0)
(setvar "cmdecho" 0)
(setvar "blipmode" 0)
(while (not (setq ent (entsel "\nSelect object near reference end: "))))
(while
(and
(not (tblsearch "block" blk))
(not (findfile (strcat blk ".dwg")))
);;and
(setq scl (getreal "\nScale Factor for Blocks: "))
(setq blk (getstring (strcat "\nBlock to use <" bk ">: ")))
(if (> blk "")(setq bk blk)(setq blk bk))
);;while
(while (setq obj (car ent)
ppt (osnap (cadr ent) "nea")
ept (vlax-curve-getEndPoint obj)
ref (vlax-curve-getDistAtPoint obj ppt)
len (vlax-curve-getDistAtPoint obj ept)
dst (getdist "\nDistance to Block Insertion: ")
)
(if (> ref (/ len 2.0))
(setq dst (- len dst))
);;setq
(setq ipt (vlax-curve-getPointAtDist obj dst)
par (vlax-curve-getParamAtPoint obj ipt)
slp (vlax-curve-getFirstDeriv obj par)
ang (atan (/ (cadr slp)(car slp)))
);;setq
(entmake
(list
'(0 . "INSERT")
(cons 2 blk)
(cons 10 ipt)
(cons 41 scl); X scale factor
(cons 42 scl); Y scale factor
(cons 43 scl); Y scale factor
(cons 50 ang)
);;list
);;entmake
)
(princ)
)

*Expert Elite*
Kent1Cooper
Posts: 5,292
Registered: ‎09-13-2004
Message 15 of 15 (638 Views)

Re: Insert Block along polyline by distance & offset

05-05-2011 09:12 AM in reply to: tommcgtx

tommcgtx wrote:

.... 

Thank you, I pasted the lines with the Z scale factor, and it works! ....

....

(cons 41 scl); X scale factor
(cons 42 scl); Y scale factor
(cons 43 scl); Y scale factor
....


I'm glad it works, but I see I didn't change the Y to a Z, to go along with changing the 42 to a 43, when I copied the Y scale factor line for the Z scale factor.  It wouldn't affect the working of it, since it's only in a comment, but for looking back at it later, you probably ought to make that correction:

....

(cons 41 scl); X scale factor
(cons 42 scl); Y scale factor
(cons 43 scl); Z scale factor
....

 

And it's interesting to know, in case it's ever needed, that if any scale factors are included in such a list, it appears all three must be.

Kent Cooper

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community