Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Trouble with extend command

4 REPLIES 4
Reply
Message 1 of 5
jschlichter
639 Views, 4 Replies

Trouble with extend command

Hi all, did some searching and couldn't find anything on the topic.

 

I'm writing a lisp routine that extends polylines to a block enitity. The code works fine from the command line but apparently doesn't run when called in the lisp routine.

 

(command "extend" hyden "" (list vline1 spoint) "")

 

where hyden is the block enitity, vline 1 is the polyline and spoint is the startpoint of the pline. Any thoughts on why this might be happening?

4 REPLIES 4
Message 2 of 5
Kent1Cooper
in reply to: jschlichter


@jschlichter wrote:

.... 

I'm writing a lisp routine that extends polylines to a block enitity. The code works fine from the command line but apparently doesn't run when called in the lisp routine.

 

(command "extend" hyden "" (list vline1 spoint) "")

where hyden is the block enitity, vline 1 is the polyline and spoint is the startpoint of the pline. Any thoughts on why this might be happening?


When you say it works from the command line, what do you mean?  Are you pasting that (command) function in there, or duplicating what it contains manually?  If you're duplicating it manually, are you actually using the variables, or selecting things?  In any case, I think it's deceiving you.

 

I saved a Block's entity name to 'hyden' and a Polyline's entity name to 'vline1' and its start point to 'spoint'.  Then I pasted that (command) function into the Command: line, and it did, in fact, extend the Polyline to the Block, but with an error message:

1 was not a valid edge or selection method.

That's true whether 'hyden' contains [you didn't specify] only the entity name of the Block reference, or the list of entity name and selection point as returned by (entsel).  It's the same if I enter the Extend command manually, and use !hyden to designate a boundary [that's where the error message comes in], followed by Enter to duplicate the "" in the code.

 

However [and here's the deceiving part], if I draw something else in between the Polyline and the Block, it only extends the Polyline to that, not to the Block.  That means it's taking the "" after hyden and the error message as the select-All-objects option for boundary edges, and not recognizing the Block entity for itself.  If some piece of that Block happens to be the first thing the extended object runs into, it will look as though it did what you want, but it didn't really -- it just extends it to "whatever."

 

When you select something that's part of a Block as a boundary for Extend or Trim, it's not using the Block itself, but the sub-entity on which you pick.  I'm sure that's why giving it a Block's entity name [or entity-name-and-selection-point list] is not accepted as valid.  After all, a Block could contain [and might contain only] things that can't be extended to [Points, 3DFaces, Dimensions, 3D Solids].  Unfortunately, using (nentsel) to save a nested entity into the hyden variable doesn't work, either, because it won't accept that as an Extend boundary [it gives a bad entity name error].  It seems unfair, since it seems to be using nested entities in ordinary Extend, but I'm not sure how you could get around it.

 

Giving it that (list) for the Polyline to extend, rather than simply spoint, puzzled me, but it seems to account for the possibility that spoint might also lie on some other entity, ensuring that the right one is extended.  I wouldn't have known you could do it that way, but it works.

Kent Cooper, AIA
Message 3 of 5
jschlichter
in reply to: Kent1Cooper

Yes, sorry, guess I should have been a little more specific.

 

hyden is the name of the selected entity only (and is only composed of lines/plines)

All the variables have been previously defined by a command (which I'm currently trying to troubleshoot)

 

I wasn't sure if I'd be able to extend to simply a "block boundary" without specifying a nested entity. That's interesting how it's extending to any object as opposed to the correct one, however, that will work for me in this case.

 

So if I'm understanding correctly (which I might not be) there's no real good option for extending to a block?

I suppose if all else fails, I could create a temporary object to extend to, then erase if afterwards.

 

Where I get really confused is when I paste this code:

(command "extend" hyden "" (list vline1 spoint) "")

 into the command line, it works (or at least gives the appearance of working), but running it from the lsp routine doesn't. I'm not sure why there would be a difference.

 

Thanks for the info Kent, that's good to know.

Message 4 of 5
Kent1Cooper
in reply to: jschlichter


@jschlichter wrote:

.... 

So ... there's no real good option for extending to a block?

I suppose if all else fails, I could create a temporary object to extend to, then erase if afterwards.

 

Where I get really confused is when I paste this code ... into the command line, it works (or at least gives the appearance of working), but running it from the lsp routine doesn't. I'm not sure why there would be a difference.

....


Do a search for "shrink wrap" [and/or "shrinkwrap" as one word], and you may find something that would make that temporary object for you.  Or, if there isn't a bunch of other stuff around, maybe you could calculate a couple of appropriate points in relation to the Block, perhaps by way of its bounding box, and have the routine select its contents using a crossing window -- that would be valid as a selection of Extend boundaries.

 

If you post the code of the surrounding routine, maybe someone will notice something about it that could explain the difference.

Kent Cooper, AIA
Message 5 of 5
jschlichter
in reply to: jschlichter

That's pretty much what I ended up doing, calculated points in relation to the block. Not what I was initially going for, but it fixed my issue.

 

Thanks for the help Kent,

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost