TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: nobody on September 01, 2016, 07:00:00 PM

Title: Variable
Post by: nobody on September 01, 2016, 07:00:00 PM
Is there another variable I can use to get a drawing scale other than dimscale?
Title: Re: Variable
Post by: MeasureUp on September 01, 2016, 07:12:51 PM
Do you mean to "set" a drawing scale? If so, then it would be text height, linetype scale.
HTH
Title: Re: Variable
Post by: dgorsman on September 01, 2016, 07:15:28 PM
There is no "drawing scale variable" as such, so the ye olde tradition has been to use the current DIMSCALE system variable.  You could add an Extension dictionary/XRecord to the document, or the model space container, which contains scale information.  You should also be able to create a custom system variable; I know it can be done with dotNET but haven't tried manual creation of the registry entries yet.
Title: Re: Variable
Post by: MP on September 01, 2016, 09:02:34 PM
Depends what you mean by scale.

In my world it means the ratio of paper space to model space.

Accordingly, you could examine the CustomScale property of non tiled viewports.

Quick & dirty for fun:

Code: [Select]
(defun c:WMS ( / ss i scale result ) ;; wuts my scale?
    (princ "\nScale: ")
    (if (setq ss (ssget "x" '((0 . "viewport")(-4 . "!=")(69 . 1))))
        (progn
            (repeat (setq i (sslength ss))
                (or
                    (member
                        (setq scale
                            (/
                                1.0
                                (vla-get-customscale
                                    (vlax-ename->vla-object (ssname ss (setq i (1- i))))
                                )
                            )
                        )
                        result
                    )
                    (setq result (cons scale result))
                )
            )
            (princ
                (if (eq 1 (length result))
                    (car result)
                    (strcat "multiples exist " (vl-princ-to-string (vl-sort result '<)))
                )
            )
        )
        (princ "unknown")
    )
    (princ)
)

WMS
Scale: 50.0

<different drawing>
WMS
Scale: multiples exist (50.0 200.0)

Cheers.
Title: Re: Variable
Post by: nobody on September 02, 2016, 02:15:55 AM
Thanks all :)
Title: Re: Variable
Post by: irneb on September 02, 2016, 02:40:57 AM
There's also CAnnoScale (Current Annotative Scale) and CAnnoScaleValue - if your drawing uses annotative scaling. Not to mention, objects could then also have one or more annotative scales attached as extension dictionaries.

Otherwise a "drawing" (especially its model space) is actually in 1:1 scale ... or should be. And as MP shows, the viewport defines the scale (or the plot setting if you print directly from model space). The DimScale is simply a setting of the current DimStyle, it may even not be used (e.g. if the DimStyle is set to auto-adjust to viewport scale, DimScale=0.0).

If you do set DimScale relevant to whatever the drawing is, chances are that you did something similar to LTScale as well - i.e. line type dash lengths should equally scale depending on the printed scaling. But similarly it could adjust per viewport if your PSLTScale is set to 1. Same goes for text heights and the TextSize variable.

E.g. going through the ACad documentation
I'd really advise you look through System Variables (http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%202010%20User%20Documentation/files/WSfacf1429558a55de1a7524c1004e616f8b-64f4.htm), perhaps use the search function there to find everything related to scales.
Title: Re: Variable
Post by: PKENEWELL on September 06, 2016, 04:35:13 PM
If you are trying to determine the drawing units - what about the MEASUREMENT system Variable? I have effectively used this variable to determine if a drawing is in metric or imperial units.


MEASUREMENT (System Variable)

Controls whether the current drawing uses imperial or metric hatch pattern and linetype files.

Type:   Integer
Saved in:   Drawing
Initial value:   0 (imperial) or 1 (metric)

Imperial; uses the hatch pattern file and linetype file designated by the ANSIHatch and ANSILinetype registry settings

Metric; uses the hatch pattern file and linetype file designated by the ISOHatch and ISOLinetype registry settings