Hi all
I have got more than 100 dxf files - rectangular plates with some holes.
I would need to 1.delete the layer "YELLOW" elements. 2. Change all 8mm holes to 6mm holes.
Is there any way to do it with a script.
I am using Autocad 2024.
Thanks.
Solved! Go to Solution.
Solved by Sea-Haven. Go to Solution.
Yes
The script is to do a dxfin or an insert into current dwg or just open the dxf.
get all objects on layer "yellow " and delete or if acad "Laydel".
Then do a simple lisp to change all 6mm Circles to 8 mm use ssget with filter correct rad=6
Save new dwg with a name. Depending on 1st step method do new dxf.
Do you understand how to make a SCRipt.
No I don't.
With help from IA I have made the code below that works when you have the dxf file open, but I don't know how to make it work in automatic, looking for all the dxf files in a directory, open them, apply the lisp, save close them.
Thank you.
(defun c:modifyDrawing (/ ss ent lay rad)
(setq ss (ssget "X" '((8 . "yellow"))))
(if ss
(progn
(command "_.erase" ss "")
(princ "\nDeleted all entities in layer 'yellow'.")
)
(princ "\nNo entities found in layer 'yellow'.")
)
(setq ss (ssget "X" '((0 . "CIRCLE"))))
(if ss
(progn
(repeat (setq i (sslength ss))
(setq ent (ssname ss (setq i (1- i))))
(setq rad (cdr (assoc 40 (entget ent))))
(if (and (>= rad 3.9) (<= rad 4.1)) ; check for radius within tolerance
(entmod (subst (cons 40 3) (assoc 40 (entget ent)) (entget ent)))
)
)
(princ "\nChanged all 8mm holes to 6mm.")
)
(princ "\nNo 8mm holes found.")
)
(princ)
)
In simple terms a script is just a sequence of command including lisp.
It would look something like this so do manually and write down all steps including enter's which are spaces in a script or a new blak line.
dxfin "dxf1"
(load "mydxffixer")
(c:modifyDrawing)
save "DXF1"
close Y
dxfin "dxf2"
(load "mydxffixer")
(c:modifyDrawing)
save "DXF2"
Close y
There are various ways to get a list of dxf file names. I would look at Lee-mac script writer.
Can't find what you're looking for? Ask the community or share your knowledge.