View Res Overkill Explode Lisp

View Res Overkill Explode Lisp

Anonymous
Not applicable
1,133 Views
3 Replies
Message 1 of 4

View Res Overkill Explode Lisp

Anonymous
Not applicable

Hello all, 

 

New to the forum. I have searched and searched and it does not seem like this particular lisp has been covered anywhere as a whole.

 

Background information: I have a bunch of drawings which were converted from Catia (when converted, it splits each sheet into its own drawing) and I was assigned with the task of taking each sheet from each Catia drawing and combining them back in to one drawing in AutoCAD. So, with AutoCAD open I would take and drag the converted Catia files onto a layout, adding a layout for each sheet and combining the converted Catia files into one AutoCAD drawing with all of the necessary sheets. When I drag the converted Catia files onto the AutoCAD layout it forms each sheet as a block. Once the Catia files were combined into one AutoCAD drawing I need to Explode, Overkill and change the View Res to 20,000 for each sheet. The drawing then needed to be Purged and Zoomed to the Extents of each Sheet and Units Changed to inches. I have taken the "ZEAS" lisp and added the command to change the View Res to 20,000.

 

Question/problem: No matter what I do I cannot get the Lisp to "Select All" "Explode" and then "Select All" "Overkill" for each sheet. I also need the Lisp to change the Units to inches. The lisp will go through each sheet, Regen All, Zoom Extents and change the View Res to 20,000 but will not Explode and Overkill. Is it possible to do this all in one lisp?

 

Any help is much appreciated, as you can imagine this has been a grueling task without such a lisp. I have been Exploding, Overkilling?, and changing the View Res manually for every sheet in every drawing. I have over 75 drawings from Catia to combine in AutoCAD each containing 20+ sheets. If I could create such a lisp it would save me hours if not days and maybe I can keep the skin on my fingertips. 

 

Here is what I have so far:

 

;File Name: ze-all-sheets
;Written By: derek 'maverick' beals
;Version: a
;Date: 08/23/06
;Description: zoom extents all sheets

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;Non-Standard Lisp Functions

(defun rtd (R) (/ (* R 180.0) pi)) ; Radians to Degrees

(defun dtr (D) (/ (* D pi) 180.0)) ; Degrees to Radians

(defun hyp (a b) (sqrt (+ (expt a 2.0)(expt b 2.0)))) ; figures hypotenuse of triangle when other 2 legs are given

(defun deg (G) (strcat G "%%d")) ; Add degree symbol to string

(defun tan (A) (/ (sin A) (cos A))) ; Tangent of variable (A) in Radians

(defun sqr (S) (* S S)) ; Squares the variable (S)

(defun feet (dec) (rtos dec 4 4)) ; converts decimal inches to feet and inches

(defun fixx (realnum) ; Rounds the variable (realnum) to the next highest whole integer (opposite of the "fix" function)
(if (> realnum (+ (fix realnum) 0))
(setq realnum (1+ (fix realnum)))
(setq realnum (fix realnum))
)
realnum
)

(defun getarc ()
(setq en (car (entsel "\nSelect Arc for Radius/Arc Length/Chord Length/Arc Angle: ")))
(setq enlist (entget en))
(setq RAD (cdr (assoc 40 enlist)))
(setq ANG1 (cdr (assoc 50 enlist)))
(setq ANG2 (cdr (assoc 51 enlist)))
(setq ANG (- ANG2 ANG1))
(if
(< ANG 0)
(setq ANG (- (* 2 pi) (abs ANG)))
)
(setq ANG3 (rtd ANG))
(setq ARCLENGTH (* RAD ANG))
(setq CHORDLENGTH (* 2 (* RAD (sin (/ ANG 2)))))
)

(defun ceiling (x n)
(setq CN (* (fix (atof (rtos (* x (/ 1.0 n)) 2 0))) n))
(if
(< CN x)
(setq CN (+ CN n))
(setq CN CN)
)
)

(setq ANGDIR 0)


(defun setvariables ()

(setq ANGBASE (getvar "ANGBASE"))
(setq ANGDIR (getvar "ANGDIR"))
(setq APERTURE (getvar "APERTURE"))
(setq ATTDIA (getvar "ATTDIA"))
(setq BLIPMODE (getvar "BLIPMODE"))
(setq CLAYER (getvar "CLAYER"))
(setq CMDECHO (getvar "CMDECHO"))
(setq OSMODE (getvar "OSMODE"))
(setq PICKBOX (getvar "PICKBOX"))
(setq TILEMODE (getvar "TILEMODE"))
)

(defun resetvariables ()

(setvar "ANGBASE" ANGBASE)
(setvar "ANGDIR" ANGDIR)
(setvar "APERTURE" APERTURE)
(setvar "ATTDIA" ATTDIA)
(setvar "BLIPMODE" BLIPMODE)
(setvar "CLAYER" CLAYER)
(setvar "CMDECHO" CMDECHO)
(setvar "OSMODE" OSMODE)
(setvar "PICKBOX" PICKBOX)
(setvar "TILEMODE" TILEMODE)
)

(setvar "blipmode" 0)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;Lisp Programming starts here

(setvariables)

(defun c:bb (/ x layouts)

(setq layouts (getvar "ctab"))

(foreach x (layoutlist)
(setvar "ctab" x)
(command "pspace")
(command "zoom" "e")
(command "viewres" "y" 20000)
(ssget "_A")
(command"explode")
(ssget "_A")
(command "overkill")

)

(command "fieldeval" 31)

(command "fielddisplay" 0)

(command "regenall")

(command "insunits" 1)


(setvar "ctab" layouts)

(princ)

 

Thanks!

0 Likes
1,134 Views
3 Replies
Replies (3)
Message 2 of 4

cadffm
Consultant
Consultant

(if (setq ss (ssget "_a" (list'(0 . "INSERT")(cons 410 (getvar 'ctab)))))
    (command "_.explode" ss "" "_.-overkill" "_p" "" "")  ; only working correctly when only ONE! INSERT is in active Space
)

 

If you want to control the Oberkill setting, edit the command

 

Commandline: -OVERKILL, follow the command procedure and write it down

Sebastian

0 Likes
Message 3 of 4

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... No matter what I do I cannot get the Lisp to "Select All" "Explode" ....


The Explode command, when called from within an AutoLisp (command) function, can Explode only one thing.  There are a couple ways around this -- Search for recent threads involving (initcommandversion) [one quite recently in connection with Exploding], and for the mysterious and undocumented QAFLAGS System Variable.

Kent Cooper, AIA
0 Likes
Message 4 of 4

braudpat
Mentor
Mentor

 

Hello

 

This routine can help you maybe !?

 

https://sites.google.com/site/cadkits/home/explodeall

 

Regards, Patrice

 

 

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


0 Likes