Jump to content

Join arc and line using AutoLISP


johnsonrod

Recommended Posts

I'm trying to join an arc and a line. I've tried the following:

 

(setq arc1 (entmakex-arc cen rad ang1 ang2 lyr))
(setq pt1 (vlax-curve-getStartPoint arc1))
(setq pt2 (vlax-curve-getEndPoint arc1))
(setq lin1 (entmakex-line pt1 pt2 lyr))
(vl-cmdf "._join" arc1 lin1)

 

'entmakex-arc' and 'entmakex-line' are functions to make the respective entities (params should be self-explanatory). This code draws the arc and the line properly but will not perform the join. I've searched the internet for an hour now, and cannot find anything that works. What is wrong with this code? Or, if there's a better way to approach this task, please tell. I've tried variations adding an empty string "" to the end of the vl-cmdf parameters, but nothing works.

 

Note that the entities are drawn in AutoCAD and I can manually join them together, so the endpoints match up, etc. But, I need to automate the join part. Any help is appreciated.

Link to comment
Share on other sites

Another.

 

(vl-cmdf "._pedit" lin1 (if (eq (getvar 'peditaccept) 0) "_Y") "" )
(vl-cmdf "._join" (entlast) arc1 "")

 

or

 

(vl-cmdf "._pedit" lin1 (if (eq (getvar 'peditaccept) 0) "_Y") "_J" arc1 "" "")

Link to comment
Share on other sites

Yes, it's always a single arc with line connecting the endpoints. This sounds like a great idea, and almost certainly more efficient than the way I'm approaching it now. I've only done really basic stuff with entmake and entmakex. Could you provide a few lines of example code for this? Thanks.

Link to comment
Share on other sites

@Tharwat and GP_

I've used a combination of your posts, and almost have a working function. It's joining the first arc/line combo, but still crapping out on me after that. I need to review other parts of the code and sort of clean house to find the issue. Probably tomorrow. Thanks for the input.

Link to comment
Share on other sites

If it is always a single arc with the endpoints connected, why not just (entmake) the LWPOLYINE ? -David

 

I was looking around for some example code for creating a polyline and found:

 

  1. http://www.theswamp.org/index.php?topic=9728.0
  2. http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/lwpolyline-with-entmake/td-p/2421606

These use a list of points to create the polyline, which is feasible, but is there any way to do it using an arc? I know I could approximate the arc by picking off a few points from the arc, but is there an exact way?

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...