oturk1 Posted August 5, 2020 Posted August 5, 2020 (edited) HI, I need to create a Lisp to do the following in a series of drawings within a folder and then save as a new file. Superflatten entire drawing. Audit and fix errors. overkill entire drawing Convert all. Purge all. Remove Hatching. Remove DIms. Create boundary box from most southern and most western extremities of building. move boundary box and content from basepoint to be 2000,2000 from 0,0. Id like to type "deepclean" as command in future, I have over 1000 drawings to run this on so ideally id like to find a routine which will automatically do this to all files within a folder, without the need to manually open each one? Edited August 5, 2020 by oturk1 added tags Quote
Steven P Posted August 5, 2020 Posted August 5, 2020 If you look at my question just before yours, there is a Lisp in there to run a script in the core console - which will sort out the batch processing, you just need to work out the script to do your stuff. Lee Mac has a script writer on his website which is probably easier. Quote
dlanorh Posted August 5, 2020 Posted August 5, 2020 2 hours ago, oturk1 said: HI, I need to create a Lisp to do the following in a series of drawings within a folder and then save as a new file. Superflatten entire drawing. Audit and fix errors. overkill entire drawing Convert all. Purge all. Remove Hatching. Remove DIms. Create boundary box from most southern and most western extremities of building. move boundary box and content from basepoint to be 2000,2000 from 0,0. Id like to type "deepclean" as command in future, I have over 1000 drawings to run this on so ideally id like to find a routine which will automatically do this to all files within a folder, without the need to manually open each one? What does "Convert All" mean? Quote
Steven P Posted August 5, 2020 Posted August 5, 2020 1 hour ago, dlanorh said: What does "Convert All" mean? had to google it... https://knowledge.autodesk.com/support/autocad/learn-explore/caas/CloudHelp/cloudhelp/2016/ENU/AutoCAD-Core/files/GUID-16097276-A292-4AFD-BA08-29F735FDB091-htm.html Quote
oturk1 Posted August 5, 2020 Author Posted August 5, 2020 convert command, its something we do to our plans which convert all splines to a particular type of PL. the system we integrate with CAD cant handle splines so is something we need to do to every plan. Quote
oturk1 Posted August 5, 2020 Author Posted August 5, 2020 3 hours ago, Steven P said: If you look at my question just before yours, there is a Lisp in there to run a script in the core console - which will sort out the batch processing, you just need to work out the script to do your stuff. Lee Mac has a script writer on his website which is probably easier. Lee Mac routines are superb, ill take a look for the batch processing part. the part i struggle with is writing the language in Lisp to get the plans cleaned up. if any help, i already have a code which deletes hatching and dims etc - see below: (defun c:cleanup (/ ss) (if (setq ss (ssget "_X" '((0 . "DIMENSION,HATCH,ATTDEF,SOLID")))) (command "_.erase" ss "") ) (vl-load-com) (or doc (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))) ) (vlax-for b (vla-get-blocks doc ) (if (and (eq :vlax-false (vla-get-isLayout b)) (eq :vlax-false (vla-get-isXref b)) ) (vlax-for o b (if (eq "AcDbHatch" (vla-get-objectname o)) (vl-catch-all-apply 'vla-delete (list o)) ) ) ) ) (vla-regen doc acAllViewports) (princ) ) Quote
Trudy Posted August 5, 2020 Posted August 5, 2020 can you upload one .dwg file here or send me on email georgiev_g96@abv.bg for testing. Quote
oturk1 Posted August 5, 2020 Author Posted August 5, 2020 17 minutes ago, Trudy said: can you upload one .dwg file here or send me on email georgiev_g96@abv.bg for testing. sure, see below. Thank you very much for the assistance 620224_Master_02.dwg Quote
Steven P Posted August 5, 2020 Posted August 5, 2020 You could try this as a very quick and probably not efficient way. it will have a dialogue box on the overkill command, but I am not sure how you would do that without it (defun c:deepclean() (command "audit" "Y") (command "overkill"(ssget "_X") "") (command "convert" "" "") (command "PURGE" "A" "*" "N") (command "PURGE" "A" "*" "N") (command "PURGE" "A" "*" "N") ;;twice to capture everything, once more for luck (c:cleanup) (command "rectang" (getvar "extmin") (getvar "extmax")) (command "move" (entlast) "" (getvar "extmin") "2000,2000") (command "PURGE" "A" "*" "N") ;;and why not? (princ) ) Normally someone better comes along and does something weird that works better soon Quote
oturk1 Posted August 5, 2020 Author Posted August 5, 2020 1 hour ago, Steven P said: You could try this as a very quick and probably not efficient way. it will have a dialogue box on the overkill command, but I am not sure how you would do that without it (defun c:deepclean() (command "audit" "Y") (command "overkill"(ssget "_X") "") (command "convert" "" "") (command "PURGE" "A" "*" "N") (command "PURGE" "A" "*" "N") (command "PURGE" "A" "*" "N") ;;twice to capture everything, once more for luck (c:cleanup) (command "rectang" (getvar "extmin") (getvar "extmax")) (command "move" (entlast) "" (getvar "extmin") "2000,2000") (command "PURGE" "A" "*" "N") ;;and why not? (princ) ) Normally someone better comes along and does something weird that works better soon The first part of this is great. the plans we are given are also a mess (see attached in previous post). if you switch to ISO SW View you'll see it was once a 3d dwg. thankfully the objects and faces are gone, so am left with a lot if lines. i need to flatten these so that it is a pure flat drawing which is 0 on the Z axis. I tried to add flatten command to the above but its throwing a few issues with selecting all and not removing hidden lines - any ideas? Also the second half of that worked slightly - however, ideally id like to be able to find the extremities of the drawing, rectangle that and then move that along with the entire drawing to 2000,2000. Apologies if this sounds a bit all over the place. Quote
ronjonp Posted August 5, 2020 Posted August 5, 2020 10 minutes ago, oturk1 said: The first part of this is great. the plans we are given are also a mess (see attached in previous post). if you switch to ISO SW View you'll see it was once a 3d dwg. thankfully the objects and faces are gone, so am left with a lot if lines. i need to flatten these so that it is a pure flat drawing which is 0 on the Z axis. I tried to add flatten command to the above but its throwing a few issues with selecting all and not removing hidden lines - any ideas? Also the second half of that worked slightly - however, ideally id like to be able to find the extremities of the drawing, rectangle that and then move that along with the entire drawing to 2000,2000. Apologies if this sounds a bit all over the place. You could use THIS to flatten the drawing. Quote
Steven P Posted August 5, 2020 Posted August 5, 2020 OK. I think I understand the second part, Replace the move line with this one (command "move" (ssget "_X") "" (getvar "extmin") "2000,2000") Quote
BIGAL Posted August 6, 2020 Posted August 6, 2020 (edited) C:cleanup will not run in aeccoreconsole has VL, but if you write a plain script it will but will use open each dwg. This can still be quick, spare pc or start a 2nd session. Edited August 6, 2020 by BIGAL 1 Quote
Steven P Posted August 6, 2020 Posted August 6, 2020 14 hours ago, BIGAL said: C:cleanup will not run in aeccoreconsole has VL, but if you write a plain script it will but will use open each dwg. This can still be quick, spare pc or start a 2nd session. Overkill doesn't work in Core Console either Quote
Steven P Posted August 6, 2020 Posted August 6, 2020 2 hours ago, Steven P said: Overkill doesn't work in Core Console either But I found this which appears to delete duplicated lines. I had to rename the function dxf and to use the ;defun c:clear rather than the one without the ';' to get it to work - not tried it in core console yet though Quote
tombu Posted August 6, 2020 Posted August 6, 2020 On 8/5/2020 at 11:06 AM, Steven P said: You could try this as a very quick and probably not efficient way. it will have a dialogue box on the overkill command, but I am not sure how you would do that without it Way to many options with the overkill command that are saved in the Windows registry. They can be modified and reset as in this example: ;| PLJOIN.LSP 2015 Version Joins lines, arcs and polylines then resets overkill defaults & combines co-linear polyline segments. If only one object is selected it joins to all connected objects. If multiple objects are selected it joins & combines co-linear polyline segments just those objects. By Tom Beauford BeaufordT@LeonCountyFL.gov Macro ^P(or C:pljoin (load "pljoin.lsp"));pljoin |; (defun c:pljoin (/ cmdecho peditaccept ss registry CombineEndToEnd CombinePartialOverlaps Ignore IgnorePolylineWidths MaintainAssociativities MaintainPolylines OptimizePolylines Tolerance) (princ "\nSelect object to join: ") (setq cmdecho (getvar "cmdecho") peditaccept (getvar "peditaccept") ss (ssget '((0 . "ARC,*LINE"))) registry (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Profiles\\" (getvar "cprofile") "\\Dialogs\\Overkill") ) (setvar "cmdecho" 0) (setvar "peditaccept" 1) (if ss (progn (command ".UNDO" "BEgin") (princ "CombineEndToEnd = ")(princ (vl-registry-read registry "CombineEndToEnd")) (setq CombineEndToEnd (vl-registry-read registry "CombineEndToEnd") CombinePartialOverlaps (vl-registry-read registry "CombinePartialOverlaps") Ignore (vl-registry-read registry "Ignore") IgnorePolylineWidths (vl-registry-read registry "IgnorePolylineWidths") MaintainAssociativities (vl-registry-read registry "MaintainAssociativities") MaintainPolylines (vl-registry-read registry "MaintainPolylines") OptimizePolylines (vl-registry-read registry "OptimizePolylines") Tolerance (vl-registry-read registry "Tolerance") ) |; (princ "\nCombineEndToEnd = ")(princ CombineEndToEnd) (vl-registry-write registry "CombineEndToEnd" "1") (vl-registry-write registry "CombinePartialOverlaps" "1") (vl-registry-write registry "Ignore" "0") (vl-registry-write registry "IgnorePolylineWidths" "0") (vl-registry-write registry "MaintainAssociativities" "1") (vl-registry-write registry "MaintainPolylines" "0") (vl-registry-write registry "OptimizePolylines" "1") (vl-registry-write registry "Tolerance" "0.000001") (if (= (sslength ss) 1) (command "_.pedit" ss "_J" "_all" "" "" "-overkill" ss "" "") ; (command "_.pedit" ss "_J" "_all" "" "" "-overkill" "L" "" "") (command "_.pedit" "_M" ss "" "_J" "_J" "_E" "0.0" "" "-overkill" "L" "" "") ;| (vl-registry-write registry "CombineEndToEnd" CombineEndToEnd) (vl-registry-write registry "CombinePartialOverlaps" CombinePartialOverlaps) (vl-registry-write registry "Ignore" Ignore) (vl-registry-write registry "IgnorePolylineWidths" IgnorePolylineWidths) (vl-registry-write registry "MaintainAssociativities" MaintainAssociativities) (vl-registry-write registry "MaintainPolylines" MaintainPolylines) (vl-registry-write registry "OptimizePolylines" OptimizePolylines) (vl-registry-write registry "Tolerance" Tolerance) |; ) (command "._UNDO" "_End") ) ) (setvar "cmdecho" cmdecho) (setvar "peditaccept" peditaccept) (princ) ) Quote
oturk1 Posted August 6, 2020 Author Posted August 6, 2020 Thanks for all the replies. I have discussed the overkill and have agreed its unnecessary and may cause more issues than it fixes. I've tried to add the flatten all command to the lisp but it says unknown command "Flatten" "all" "N" Why would it fail in lisp? Also you all talk about core console - I've never heard of this before, can anyone enlighten me please? Quote
BIGAL Posted August 6, 2020 Posted August 6, 2020 (edited) Google Aeccoreconsole it is Autocad running with no user input but carry out amendments to multiple dwg's. It can be ran from the winodws CMD line as a batch file c:\Program files\Autodesk\Autocad 2020\accoreconsole.exe /i d:\alan\test1.dwg /s d:\alan\lisp\test.scr c:\Program files\Autodesk\Autocad 2020\accoreconsole.exe /i d:\alan\test2.dwg /s d:\alan\lisp\test.scr c:\Program files\Autodesk\Autocad 2020\accoreconsole.exe /i d:\alan\test3.dwg /s d:\alan\lisp\test.scr Or auto process a series of dwgs in a folder. https://through-the-interface.typepad.com/through_the_interface/2012/02/the-autocad-2013-core-console.html Edited August 6, 2020 by BIGAL Quote
Recommended Posts
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.