Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
*Expert Elite*
Kent1Cooper
Posts: 5,293
Registered: ‎09-13-2004
Message 11 of 44 (663 Views)

Re: How to insert block at every vertice of a polyline in lisp?

08-11-2009 07:43 AM in reply to: *Jd
It works for me. If you edited it, for example to specify a particular Block name, or to add a request to the User to supply one, might you have gotten something wrong in parentheses or quotes or something?

On the other hand, if you didn't edit it at all, and don't have any block name set into the yourblockname variable, I think that would explain the problem. The variable name would return nil, which would cancel the Insert command. The point would be fed in, but not really mean anything since it wouldn't be in a command any more. The first "" [Enter] would try to recall the BlockVert command, which would work if you did it manually. But (defun)'d command names can't be used in (command) functions in the way that regular AutoCAD command names can [e.g. (command "BlockVert" ...) won't know what you're talking about; you would have to do (C:BlockVert) instead]. I expect that is the source of the error message. Try doing (setq yourblockname "whatever") first, putting a real block name in place of the whatever, and see whether it works. That's what I did to test it.

--
Kent Cooper Edited by: Kent1Cooper on Aug 11, 2009 1:01 PM
[added second paragraph]
Kent Cooper
Valued Contributor
flopo
Posts: 50
Registered: ‎09-02-2009
Message 12 of 44 (663 Views)

polyline vertex

09-02-2009 01:07 AM in reply to: *Jd
Hello,
I'm trying to insert a block at every vertex of a polyline. Do you know how to do this? Or you have a lisp for this? Thanks!
Valued Contributor
flopo
Posts: 50
Registered: ‎09-02-2009
Message 13 of 44 (663 Views)

Re: How to insert block at every vertice of a polyline in lisp?

09-02-2009 01:45 AM in reply to: *Jd
I tried to run this lisp, it doesn't work. Let's say my block name is "vertex", can you tell me what should i modify in your routine to work? Sorry for my english... Thanks! Edited by: flopo on Sep 2, 2009 12:19 PM
Valued Contributor
flopo
Posts: 50
Registered: ‎09-02-2009
Message 14 of 44 (663 Views)

Re: How to insert block at every vertice of a polyline in lisp?

09-02-2009 02:26 AM in reply to: *Jd
hello jd
Have you succeed runing this routine ? Can you help me please? Thanks!
*Expert Elite*
Kent1Cooper
Posts: 5,293
Registered: ‎09-13-2004
Message 15 of 44 (663 Views)

Re: How to insert block at every vertice of a polyline in lisp?

09-02-2009 05:47 AM in reply to: *Jd
Replace the line that says:

yourblockname

with:

"vertex"

including the quotation marks.

--
Kent Cooper
Kent Cooper
*Some Buddy
Message 16 of 44 (663 Views)

Re: polyline vertex

09-02-2009 06:01 AM in reply to: *Jd
Hi,

You could use the old school DXF codes to extract the vertices from the
polyline's (entget ...) returned stuff, or you can use the new ActiveX
enabled VisualLISP to extract the same vertices using the Coordinates
property. With the latter, you will get a flat list, so you will have to
group the values in order to create a list of valid points lists, something
like '((x1 y1)(x2 y2) x3 y3)(xn yn)) for a lwpolyline or '((x1 y1 z1)(x2 y2
z2) x3 y3 z3)(xn yn zn)) for the old format polyline.

Then you will use these points in a loop, calling the insert command and
using each vertex from the previous list as insertion point for your block.

As a matter of fact, I think I've already seen this one being discussed
here, so you could search the web or the forum and you might have some code
too.

HTH

--
Humans are born with a wide horizon.
As time goes by, the horizon narrows and
narrows, until it becomes a point of view.


a écrit dans le message de news: 6247359@discussion.autodesk.com...
Hello,
I'm trying to insert a block at every vertex of a polyline. Do you know how
to do this? Or you have a lisp for this? Thanks!
Valued Contributor
flopo
Posts: 50
Registered: ‎09-02-2009
Message 17 of 44 (663 Views)

Re: How to insert block at every vertice of a polyline in lisp?

09-02-2009 09:54 PM in reply to: *Jd
Thank you, Kent. It is working. Thank a lot!!!
Valued Contributor
flopo
Posts: 50
Registered: ‎09-02-2009
Message 18 of 44 (663 Views)

Re: How to insert block at every vertice of a polyline in lisp?

09-02-2009 11:52 PM in reply to: *Jd
Hi Kent,
In your lisp Blockvert, if the block that i want to insert has attributes, is it possible to be an attribute that count the number of vertices? For example, to be... V1, V2....V100? More than this, can be something like V1-0, V2-181.75 , V3-324.18 - i mean , to be an order number + the lenght of the polyline from the beginning to the vertice ? maybe I ask to much... Thanks!!
*Expert Elite*
Kent1Cooper
Posts: 5,293
Registered: ‎09-13-2004
Message 19 of 44 (663 Views)

Re: How to insert block at every vertice of a polyline in lisp?

09-03-2009 05:33 AM in reply to: *Jd
I have approximately zero experience working with Attributes, but if the insertion just has an additional prompt asking for a text-string value to give to one, then yes, you should be able to answer that prompt with something like this:

(strcat
"V"
(itoa inc)
"-"
(rtos (vlax-curve-getDistAtParam plobj inc) 2 2)
); end strcat

That would label the starting vertex as V0, its parameter number. If you want that labeled V1, replace (itoa inc) with (itoa (1+ inc)).

--
Kent Cooper


flopo wrote...
....is it possible to be an attribute that count the number of vertices? For example, to be... V1, V2....V100? More than this, can be something like V1-0, V2-181.75 , V3-324.18 - i mean , to be an order number + the lenght of the polyline from the beginning to the vertice ?
Kent Cooper
Valued Contributor
flopo
Posts: 50
Registered: ‎09-02-2009
Message 20 of 44 (663 Views)

Re: How to insert block at every vertice of a polyline in lisp?

09-04-2009 03:16 AM in reply to: *Jd
Hi Kent,
I don't know what you mean by additional prompt to the insertion.


(strcat
"V"
(itoa inc)
"-"
(rtos (vlax-curve-getDistAtParam plobj inc) 2 2)
); end strcat


Should i ad this to the lisp Blockvert?
Thanks

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