Jump to content

insert vertex


giskumar

Recommended Posts

Hi all,

 

can any one help me how to insert a vertex in a 2d polyline with out using vlisp.

I need this routine for intelli cad.

 

Thanks

Link to comment
Share on other sites

I am not shure about AutoCAD 2006... but doubleclick the polyline, then you get some sort of menu / options. Choose "insert" and select a location for the new vertex (like "nearest"). Now leave the command and select the polyline again (single click). If all is right you see the new vertex.

 

Is this what you need?

 

Regards,

MarcoW.

Link to comment
Share on other sites

Thanks for the reply.

 

I want to do this using purly lisp functions instead of using Visual lisp functions.

bcz Intelli cad does't support Visual lisp.

 

thanks.

Link to comment
Share on other sites

It can be done, but can also be a fairly involved process if the added vertex is in an arc (bulge) segment of the pline. Also plines with varying widths can be a challenge. What are the parameters that you need to meet? -David

Link to comment
Share on other sites

Are the polylines always going to be LWPolies? Or are you going to have the older 2d Polies as well? With the 2dPolies you have to recreate the poly from scratch, since the polyline actually consists of the PolyLine entity, followed by Vertex entities, and ended by a SeqEnd entity. So you'd have to erase all and create them again. See the developer help on creating complex DXF entities.

 

With LWPolyline the vertexes are simply groups of DXF code 10, 40, 41 & 42 for each vertex. So you need to insert those codes for the new vertex into the correct spot in the DXF list - "easiest" way is to run through each item before that position (adding them to a new temporary list), then add your new items, and finally continue to add the rest from the old list. Then change the code 90 to update the number of vertices in total - uses subst for that. And finally use entmod to update the entity to the adjusted DXF data list.

 

BTW, which IntelliCAD are you using? I know some of them work with the vlax functions as well (e.g. BricsCAD)

Link to comment
Share on other sites

Thanks for all,

 

finally i succed with the following that i had written.

Please advise any improvements.

 

(defun c:ins(/ obj obj1 po str)
(setq obj (entsel "\n Select entity to insert vertex"))
(setq obj1 (car obj))
(setq po (cadr obj))
(if (/= (cdr (assoc 0 (entget (car obj)))) "LWPOLYLINE")
(progn
(alert "The selected line is not polyline")
(setq str (getstring "\n Do u want to continue: <y / n>"))
(cond
((= str "y")
(progn
(command "pedit" obj "")
(setq obj1 (entlast))
));cond
);cond
));if
(if (= (cdr (assoc 0 (entget obj1))) "LWPOLYLINE")
(progn
(command "break" obj1 po po)
(command "pedit" obj1 "j" (entlast) "" "")
))
)

Link to comment
Share on other sites

That's possibly a good way. Just be careful of breaking on the selected point if there's object snaps set. You could add "_None" just before passing each point to the break command. And I'd be a bit sceptical about using the selected point directly. It's hardly ever going to be directly on top of the polyline. But it's going to be really complex to figure out such point on a curved section of the polyline. That's where I'd have wanted the vlax-curve functions, but you state they're not available to you :ouch:

 

Is that where you want to stop the routine? Or do you want to move the newly inserted vertex to a new position?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...