CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor, Revit and other Autodesk products [www.cadforum.cz] ARKANCE | CONTACT | CAD ESHOP - CZ | SK | EN | DE
Over 1.077.000 registered users (EN+CZ). New 1D nesting and 3D nesting tools, updated Color converter. New AutoCAD 2025 commands and variables. Learn about twiGIS.

CAD tip CAD tip # 10884:

Question

CAD 
 %  platform  category 
A
If you to find in your utility or menu-macro whether the current drawing is a 2D or 3D drawing file, or whether it doesn't contain any visual entities, you can use the following simple AutoLISP functions (predicates):

;is current drawing 2D? (defun is2D-p () (and (zerop (caddr (getvar "EXTMIN")))(zerop (caddr (getvar "EXTMAX")))) ; Z-boundingbox = 0? ) ;is current drawing 3D? (defun is3D-p () (< (caddr (getvar "EXTMIN"))(caddr (getvar "EXTMAX"))) ; Z-boundingbox ? ) ;is current drawing visually empty? (vl-load-com) (defun isEmpty-p () (vla-regen (vla-get-activedocument (vlax-get-acad-object)) 1) (> (caddr (getvar "EXTMIN"))(caddr (getvar "EXTMAX"))) ; min>max? )

The functions - e.g. (is2D-p) - return the values of T (true) or nil (false) in AutoCAD.

ACAD
100% *CAD
4.5.2016    7541×  
Prices - CAD eShop:
applies to: AutoCAD ·

See also:
Tip 14316:How to redefine the HATCH command to start with the settings option?
Tip 14063:How to get week day and week number from a given date.
Tip 14027:3D heart from the heart.
Tip 14006:Universal MsgBox in AutoLISP.
Tip 13960:Fermat's spiral in AutoCAD.


Back   All CAD Tips



Have we helped you? If you want to support the CAD Forum web service, consider buying one of our CAD applications, or our custom software development offerings, or donating via PayPal (see above). You may also add a link to your web - like this "fan" link: CAD Forum - tips, utilities, blocks for Autodesk products
CAD: 
OS: 
Categ: 
Text:
 FAQ
  



Featuring:
Increase your productivity with our set of add-on functions for AutoCAD Civil 3D
CADstudio Civil Tools More info


Please use these tips at your own risk.
Arkance Systems is not responsible for possible problems that may occur as a result of using any of these tips.
TOPlist