Is it possible to remove vertices from a hatch with lisp?

Is it possible to remove vertices from a hatch with lisp?

jamieq
Collaborator Collaborator
2,368 Views
20 Replies
Message 1 of 21

Is it possible to remove vertices from a hatch with lisp?

jamieq
Collaborator
Collaborator

I'm writing a lisp function that will include removing hatch vertices, but I'm having some trouble. With a polyline you can remove a vertex and the other associated entries from the object's entities and then entmod. That doesn't work with a hatch. In fact, a hatch's entities list seems like it can be a couple different ways. If the hatch was made by selecting an object, then the sides between vertices (for lines only, arcs are quite different) are listed with a (72 . 1) then a DXF code 10 point and DXF code 11 point. If the hatch was made by selecting a point, then the vertices are listed as a series of DXF code 10 points. My thinking was if I removed the appropriate items from the list of entities and then ran entmod on that new list, the hatch would update without the removed vertex/vertices. But this doesn't happen. Instead I just get a return of nil. Is there a way to actually do this by entmodding?

 

I've tried a couple other ways, including recreating the hatch boundary, modding that pline, then disassociating the hatch and deleting the pline. But if the hatch has multiple boundaries, or any internal islands, it all falls apart as multiple plines are recreated and it just becomes a big giant mess. So I'm hoping there's another way I can do this an easier way. 

0 Likes
2,369 Views
20 Replies
Replies (20)
Message 2 of 21

pendean
Community Legend
Community Legend
How do you want to pre-determine which vertices to remove from these hatches exactly (and which to keep)?
0 Likes
Message 3 of 21

jamieq
Collaborator
Collaborator
Possibly by getpoint selection, or maybe by vertices within a window. For purposes of this conversation, let's just assume I have a point that matches a hatch vertex and I'm trying to remove that vertex from the hatch.
0 Likes
Message 4 of 21

hak_vz
Advisor
Advisor

@jamieq 

You don't need lisp for this.

Start command HATCHEDIT, use option to recreate hatch boundary as a polyline, and make hatch associative to recreated polyline boundary. Click on recreated (or already existing boundary polyline), and hover over vertex you want to remove. Dialog pops up with options to stretch, remove or add vertex. After you remove some vertex, hatch entity will update automatically.

Working with hatch entity is complex in autolisp, especially using dxf codes, since there are different types of hatches,

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 5 of 21

jamieq
Collaborator
Collaborator
I appreciate the reply, but I'm trying to do this specifically with lisp.
0 Likes
Message 6 of 21

hak_vz
Advisor
Advisor
(command "-hatchedit" OBJ "b" "r" "y")

Use this for start, make hatch object associative to poylyline and create code to add or remove polyline vertex.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 7 of 21

Kent1Cooper
Consultant
Consultant

@hak_vz wrote:
(command "-hatchedit" OBJ "b" "r" "y")

Use this for start, make hatch object associative to poylyline and create code to add or remove polyline vertex.


I think you want the recreated Boundary to use the Polyline option in there, not the Region option.  Regions have utterly inscrutable entity data, and I don't think vertices in them can be manipulated in AutoLisp.

Kent Cooper, AIA
Message 8 of 21

jamieq
Collaborator
Collaborator
Again, I appreciate the reply, but that's exactly how I've already implemented it. I mentioned in the original post that I've used that method. The problem is, if the hatch has multiple boundaries or any internal islands, then that method gets super messy really quick. When the hatch boundary is recreated, each boundary is a new pline. And if more than pline is created, it becomes difficult to get entities before entlast, since deleting entlast to get the second to last entity destroys the hatch association.

That said, while writing this reply, I read another forum thread about working backwards from entlast, and someone suggested setting a bookmark with entlast before creating new entities then using entnext from the bookmark. So that's exactly what I'm going to do so I can capture all the boundary plines that come from recreating the boundary.
0 Likes
Message 9 of 21

john.uhden
Mentor
Mentor

INSCRUTABLE.  That's the perfect word!

Nice, @Kent1Cooper .

John F. Uhden

0 Likes
Message 10 of 21

Kent1Cooper
Consultant
Consultant

@john.uhden wrote:

INSCRUTABLE.  That's the perfect word!

Nice, @Kent1Cooper .


INDUBITABLY!

Kent Cooper, AIA
0 Likes
Message 11 of 21

jaruugarte
Contributor
Contributor

hi @jamieq 

 

looking for a solution, I found these two files that manage to do what you ask, but it is in two steps that it is achieved.

with "HTCHEDIT" command recreate the boundary off the hatch, and with the "addv.vlx" file, you can modify the polyline vertex, which was generated by boundary.

 

Hope this helps you

 

Best regards.

 

 

Ing. Jaruzelsky Ugarte
Diseñador Vial
Mail: jaruugarte@hotmail.com
Tel:(505)5776-0506 – Claro
0 Likes
Message 12 of 21

jamieq
Collaborator
Collaborator

Thank you for the response and the files. However, addv.vlx appears to only have a routine to add vertices to polylines. I don't think this will help what I'm trying to accomplish. 

0 Likes
Message 13 of 21

jaruugarte
Contributor
Contributor

when you load the app, this send a message, not only have command to add vertices, but have a command "delv", you can read in the command prompt.

 

Regards 

Ing. Jaruzelsky Ugarte
Diseñador Vial
Mail: jaruugarte@hotmail.com
Tel:(505)5776-0506 – Claro
0 Likes
Message 14 of 21

Kent1Cooper
Consultant
Consultant

@jamieq wrote:

.... addv.vlx appears to only have a routine to add vertices to polylines. I don't think this will help .... 


A similar routine to remove vertices should work, if the Hatch object is Associative, and is tied to the Polyline boundary.  Then if you change the Polyline [in any way, not only by removing vertices], the Hatch will follow.

Kent Cooper, AIA
0 Likes
Message 15 of 21

jamieq
Collaborator
Collaborator
Didn't see that. Thank you.
0 Likes
Message 16 of 21

john.uhden
Mentor
Mentor

@jamieq 

In keeping with what @Kent1Cooper pointed out, I think the one-step solution would be one routine to...

  1. If there is no associative boundary, then recreate the boundary as associative.
  2. Include code like my VEDIT routine to add or remove vertices to/from the boundary.
  3. Remove the boundary if recreated.

 

Hmm, I could use this myself if I also added bulge modification.

Ya know, if you grip the hatch you can move, add, and remove vertices.  There's just no way to add or remove bulges.

John F. Uhden

0 Likes
Message 17 of 21

Kent1Cooper
Consultant
Consultant

@john.uhden wrote:

....

Ya know, if you grip the hatch you can move, add, and remove vertices.  There's just no way to add or remove bulges.


If you pick the midpoint grip on a segment, you can use the Convert to [Arc or Line, depending] option.  But I think converting to an Arc segment is limited to dragging the midpoint -- I don't think you can specify a bulge factor, for instance, or a radius.

Kent Cooper, AIA
0 Likes
Message 18 of 21

john.uhden
Mentor
Mentor

@Kent1Cooper wrote "If you pick the midpoint grip on a segment, you can use the Convert to [Arc or Line, depending] option."

Thanks, Kent.  I think I had stumbled on that once, and of course forgot.

So the OP's solution is simply to grip the hatch and reconfigure its shape.

I will remember that now.

John F. Uhden

0 Likes
Message 19 of 21

Kent1Cooper
Consultant
Consultant

@john.uhden wrote:

....

So the OP's solution is simply to grip the hatch and reconfigure its shape.

....


[If done manually, yes.  But see the Topic wording, and Messages 3 & 5.]

Kent Cooper, AIA
0 Likes
Message 20 of 21

Sea-Haven
Mentor
Mentor

is it quicker read hatch properties, then delete hatch, pick pline etc makes new "ASSOCITIVE" hatch with old properties, so edits work next time. 

0 Likes