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.
Edited by: Kent1Cooper on Aug 11, 2009 1:01 PM
[added second paragraph]
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
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
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: email@example.com...
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!
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!!
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:
That would label the starting vertex as V0, its parameter number. If you want that labeled V1, replace (itoa inc) with (itoa (1+ inc)).
....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 ?