Hi,
I'm checking model files for properties and settings, and was wondering if there is a way to get DWGUNITS in the same manner as for exampel INSUNITS, where I get returned with the inserted value (without changing it).
I understand that DWGUNITS checks multiple parameters, for example lunits and luprecision. But it still has a value <X> (3 or 6 for mm and m), which I would like to return.
My check of INSUNITS that can be either 4 or 6 looks like this:
(setq TEST_INSUNITS_4 (= 4 (getvar "INSUNITS")))
(setq TEST_INSUNITS_6 (= 6 (getvar "INSUNITS")))
(setq RESULT
(strcat
(cond
(TEST_INSUNITS_4
"\nINSUNITS\t\t = 4 \t- OK")
(TEST_INSUNITS_6
"\nINSUNITS\t\t = 6 \t- OK")
(t (strcat "\nINSUNITS\t\t = " (itoa (getvar "INSUNITS")) "\t- WRONG, SHOULD BE 4 OR 6"))
)
)
)
(alert RESULT)
I am then returned with a dialogbox, stating if INSUNITS is 4, 6 och something else (WRONG..).
Why is it not possible to do the exact same for DWGUNITS?
@ludvig.linderV5RB6 wrote:
....
Why is it not possible to do the exact same for DWGUNITS?
Because DWGUNITS is not a System Variable.
Can you explain more what your end goal is? Are you only trying to display certain text to the user? change something in the drawing?
We do not know what your definition of "DWGUNITS" is, can you elaborate more on what you're trying to accomplish please.
Best,
~DD
Well, TBH it looks like you already have a pretty good grasp on what variables you need to check. Here's a complete list just in case you need a couple more.
Does this help? do you need anything further?
Best,
~DD
After more research about -DWGUNITS and how that command works/affects the drawing, I see that I have not fully answered your question.
I will have to do more research and get back with you.
Here's a good start though:
https://forums.autodesk.com/t5/autocad-forum/dwgunits-documentation/td-p/2527820
Best,
~DD
Well, this is a lot deeper than I was expecting to dive today, but here's the results.
First, a few things must be established...
- The "-DWGUNITS" command I do not believe is available in Vanilla AutoCAD, I think it's only specific to certain verticals.
- The "-DWGUNITS" command is also an AEC command: -AECDWGSETUP (...under the "Units" option)
- In addition to a Command Line interface (the default you're used to seeing) we also have a Dialog Box option to interact with these settings, with this command: AECDWGUNITSETUP (image below).
Now, I will dig into how we can access some of these items. I will have a couple Code Samples below, but ALL of the code samples will reference a global variable ("*docC3D*") that I establish with this code (I believe it is compliments of user: Jeff_M, who hangs out over in the Civil 3D Customization forum a lot):
;; Returns the AeccXUiLandLib Interface object (as vla object) ;; (the primary object that allows us to edit 'Civil' related items [alignment, surface, points, etc.]) ;; Also sets as global var (defun C3D-GetC3D ( / C3D) (setq C3D (strcat "HKEY_LOCAL_MACHINE\\" (if vlax-user-product-key (vlax-user-product-key) (vlax-product-key) );if );strcat C3D (vl-registry-read C3D "Release") C3D (substr C3D 1 (vl-string-search "." C3D (+ (vl-string-search "." C3D) 1)) );substr *C3D* (vla-getinterfaceobject (vlax-get-acad-object) (strcat "AeccXUiLand.AeccApplication." C3D) );vla-getinterfaceobject );setq );defun ;; Returns the active C3D document (as vla object) ;; Also sets as global var (defun C3D-GetC3DActiveDocument ( / ) (setq *docC3D* (vla-get-activedocument *C3D*)) );defun
Here is a screenshot for reference. I will Not be going through all of the tabs because I believe this is enough information to get you on the right track.
Code Sample: 1
Reference (aeccDrawingUnitFeet = 1): http://docs.autodesk.com/CIV3D/2012/ENU/API_Reference_Guide/com/AeccXLandTypesLib__AeccDrawingUnitTy...
(setq tmp *docC3D* dwgUnits (foreach x '("Database" "Settings" "DrawingSettings" "UnitZoneSettings" "DrawingUnits") (setq tmp (vlax-get tmp x)) );foreach );setq
Code Sample: 2
Reference: http://docs.autodesk.com/CIV3D/2012/ENU/API_Reference_Guide/com/AeccXLandLib__IAeccSettingsArea.htm
(setq tmp *docC3D* areaType (foreach x '("Database" "Settings" "DrawingSettings" "AmbientSettings" "AreaSettings" "Unit" "Value") (setq tmp (vlax-get tmp x)) );foreach );setq (setq tmp *docC3D* areaPrecision (foreach x '("Database" "Settings" "DrawingSettings" "AmbientSettings" "AreaSettings" "Precision" "Value") (setq tmp (vlax-get tmp x)) );foreach );setq
Code Sample: 3
(setq tmp *docC3D* dwgUnits (foreach x '("Database" "Settings" "DrawingSettings" "UnitZoneSettings" "ScaleObjectsFromOtherDrawings") (setq tmp (vlax-get tmp x)) );foreach );setq
Code Sample: 4
(setq tmp *docC3D* volumeType (foreach x '("Database" "Settings" "DrawingSettings" "AmbientSettings" "VolumeSettings" "Unit" "Value") (setq tmp (vlax-get tmp x)) );foreach );setq (setq tmp *docC3D* volumePrecision (foreach x '("Database" "Settings" "DrawingSettings" "AmbientSettings" "VolumeSettings" "Precision" "Value") (setq tmp (vlax-get tmp x)) );foreach );setq
Hope this helps!
Best,
~DD
Hi,
I have a similar problem to the original post. I need to read the LUNITS in autocad 2013.
Your answer was the best that i have found so far, but it will not work with autocad version 2013.
Although the -dwgunits is available as a command, AECDWGSETUP is missing cause, as you 've already said, it seems that is not available in vanilla autocad.
I have no experience with Visual LISP extention and ActiveX methods, just a basic undrestanding of autolisp (enough to do basic thinks by copying - pasting some code).
Any ideas will be mostly appreciated.
Thanks in advance,
Yiannis
It sounds like you should be using the (getvar ...) function to retrieve the LUNITS variable.
Maybe something like this:
(defun c:TEST ( / LU LUdesc)
(setq LU (getvar 'LUNITS))
(setq LUdesc
(cdr (assoc LU
'((1 . "Scientific") (2 . "Decimal") (3 . "Engineering") (4 . "Architectural") (5 . "Fractional"))
))
)
(alert
(strcat "\nYour units are currently: " LUdesc)
)
(princ)
)
Best,
~DD
Another approach [no variables needed, nor an association list since the values are a contiguous series of integers]:
(defun C:LUR (); = Linear Units Report
(alert
(strcat
"\nLinear units are currently set to "
(nth (1- (getvar 'LUNITS)) '("Scientific" "Decimal" "Engineering" "Architectural" "Fractional"))
"."
)
)
(prin1)
)
Hi
Here is a lisp to extract DWGUNITS
http://autolisps.blogspot.com/p/getdwgunits.html
I may be late to the game and you're past this point but perhaps using the brute force way if you don't know what your looking for or just want an education on all it will do.
Use sysvdlg and save out the svf file make your changes or open up another file then save out another svf file with sysvlg. Do a compare and see what vars changed. That will give you at least a jumping off point finding those pesky hidden vars no one thinks about.
Can't find what you're looking for? Ask the community or share your knowledge.