Jump to content

AutoLisp Select All Arcs increase radius by fixed amount


Tricon

Recommended Posts

Hello Folks,

 

I have a quantity of drawings. Each drawing has several arcs in it. I need to increase the radius of the arc by 0.5mm (units).

 

I have discovered that I may be able to use selection sets by running a script called from the command line.

 

I have experimented and it appears that I can create a selection set of all arcs:

 

(ssget "_X" '((0 . "ARC")))

Autocad command line replies:

 

 

What I do not know is how to proceed.

 

Can I now increase all entities in this selection set by 0.5 units? How is it done?

 

If any one can provide some guidance or a reference for the process, it would be appreciated.

 

Kind regards,

 

Daniel.

Link to comment
Share on other sites

Working out the points of the new arcs seems difficult in my view. I would however use vl-offset to create a new arc and vl-delete the old.

 

Sent from my Pixel XL using Tapatalk

 

P.S

That is providing your ok with the entire arc moving, do you need one end point the same, the center point, both?

Link to comment
Share on other sites

I found a solution. Code from here:

 

http://www.cadtutor.net/forum/showthread.php?63828-Increase-Arc-Circle-Radius-Diameter&p=435221&viewfull=1#post435221

 

And I adapted it thus:

 

(setq s (ssget "_X" '((0 . "ARC"))))
(repeat (setq i (sslength s))(setq e (entget (ssname s (setq i (1- i)))))(entmod (subst (cons 40 (+ (cdr (assoc 40 e)) 0.5))(assoc 40 e) e)))

 

Now to put it into the batch file...

 

(Sorry, I am not allowed to fix my post above to incorporate the

 tag.)
Link to comment
Share on other sites

Hi, this should increase the radius by 0.5 for all arcs on thawed layers. paste into the command line

 

( (lambda ( ss / num ent rad )
   (repeat (setq num (sslength ss))
     (setq ent (entget (ssname ss (setq num (1- num)))))
     (setq rad (cdr (assoc 40 ent)))
     (entmod (subst (cons 40 (+ rad 0.5)) (cons 40 rad) ent))
   )
 )
 (ssget "_A" '((0 . "ARC")))
)

Link to comment
Share on other sites

The critical issue is not the arc but the line ends, another very good solution is Dynamic arc by Alan J Thomson it allows you to drag the arc size but I am sure it could be changed to just alter the radius a fixed amount.

Link to comment
Share on other sites

Thanks Bigal. Yes, I could see how line ends would be a problem. I am lucky as my problem is fairly easy. (Apologies, I negected detail). All parts are gusset type flat plates for structural steel interconnects. When exported from what ever package was used to develop the parts all items are polylines. I explode these parts. I am only interested in the 'bolt holes' that after exploding become two arcs. I need to increase the hole diameter by 1mm so +0.5 to each arc.

 

The outside of the shape is simply straight lines. This makes the problem easy. I would need to work much harder if I needed to determine if the arcs were internal or external and only modify the internal arcs that formed the holes.

 

What I have works with some prolems (my post from yesterday has not been released. I think it was becase I credited the idea below with a link). So here is the code that did work (before FrankinBeans reply).

 

(setq s (ssget "_X" '((0 . "ARC"))))
(repeat (setq i (sslength  s))(setq e (entget (ssname s (setq i (1- i)))))(entmod (subst (cons 40  (+ (cdr (assoc 40 e)) 0.5))(assoc 40 e) e)))

 

If the part has no holes or acs then the script fails and I need to manually interact to fix the problem.

 

I run the code below as a batch file: (Initial idea credited to 'Panic Mode')

 

FILEDIA 0
limits -10000,-10000
10000,10000
explode all

all
explode all
(setq s (ssget "_X" '((0 . "ARC"))))
(repeat  (setq i (sslength s))(setq e (entget (ssname s (setq i (1-  i)))))(entmod (subst (cons 40 (+ (cdr (assoc 40 e)) 0.5))(assoc 40 e)  e)))
SAVEAS



Y
FILEDIA 1
QUIT

 

It falls over sometimes but if I was to sort out all parts with holes first (probably need to do this manually by eye) into one directory I could then batch the files and all would be OK (it seems)

 

for %%D in (*.dxf) DO "[path to]\acad.exe" %%D /B "[path to script]\script.scr"

 

Much easier than doing it by hand.

 

I wish it was possble to run the script without opening a GUI to ACAD as this takes the most time now.

Link to comment
Share on other sites

If your cutting the parts (laser/plasma/whatever) from these profiles then changing the 2 arcs to 1 correct diameter circle would be better for the process.

 

Sent from my Pixel XL using Tapatalk

Link to comment
Share on other sites

fyi, the code you have already is the same method I posted, might as well stick with that but you can stop it failing when no arcs exist by adding an 'if' condition..

[color=red](if[/color] 
(setq s (ssget "_X" '((0 . "ARC"))))
(repeat (setq i (sslength  s))(setq e (entget (ssname s (setq i (1- i)))))(entmod (subst (cons 40  (+ (cdr (assoc 40 e)) 0.5))(assoc 40 e) e)))
[color=red])[/color]

Link to comment
Share on other sites

Thank you Dan113. Yes, I agree this would be good. I am lucky that the processing software I use does this for me automatically. From what I am quickly learning, this would not be overly difficult given what I start with.

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