Jump to content

Determine drawing units and scale accordingly


pixel8er

Recommended Posts

Hi all

 

I'm wondering how to add a bit of code that will determine if the units of a metric drawing is metres or millimetres and then add the appropriate scale value.

 

The code snippet I have is below and at present is correct for millimetres drawings...

 

(setvar "dimscale" (/ 1.0 (getvar "CANNOSCALEVALUE")))

 

...and for metres drawings this is the code...

 

(setvar "dimscale" (/ 0.001 (getvar "CANNOSCALEVALUE")))

 

So what I'm thinking is that the new code could determine the UNITS or even INSUNITS with an IF statement and apply the correct code based on that.

 

Is that viable? Anyone got any hints?

 

Thanks

Paul

Link to comment
Share on other sites

I am illisperate, so can't help you with a lisp solution, but I use a MODE MACRO which checks the MEASUREMENT value of any drawing upon which I am working, ostensibly to alert me to any issues.

Link to comment
Share on other sites

Thanks Dadgad. The MEASUREMENT could work well too. I'm hoping someone might have a little snippet of code that implements it to check and then based on the value return either of my 2 code snippets

Edited by pixel8er
Link to comment
Share on other sites

So what I am hoping to achieve is:

 

If insunits = 4 then apply this

(setvar "dimscale" (/ 1.0 (getvar "CANNOSCALEVALUE")))

 

if insunits = 6 then apply this

(setvar "dimscale" (/ 0.001 (getvar "CANNOSCALEVALUE")))

 

if insunits = anything else then return message "Your drawing units need to be set to metres or millimetres"

 

But I'm not sure of the correct code syntax to achieve that.

Link to comment
Share on other sites

Doesn't CANNOSCALE and CANNOSCALEVALUE just deal with Annotation scales? They can be set different than what the drawing is drawn in and wouldn't matter if no annotation objects are in the drawing.

 

Doesn't MEASUREMENT just determine to use Imperial or Metric Hatch Patterns and Linetypes, etc.?

 

INSUNITS specifies a drawing units value for automatic scaling of blocks, images, or xrefs inserted or attached to a drawing and has no bearing to what the drawing could actually be drawn in, it could be set to Unitless or whatever even millimeters in an Imperial drawing. Not to mention the value is ignored by annotative blocks.

 

I'm not aware of a sysvar that determines whether a drawing is Meters or millimeters except -DWGUNITS.

 

As for coding, maybe someone will pop in soon and offer some suggestions, but I am just trying to save you some effort by letting you know INSUNITS, CANNOSCLEVALUE are not a good way to determine what units a drawing is drawn in.

Link to comment
Share on other sites

Doesn't CANNOSCALE and CANNOSCALEVALUE just deal with Annotation scales? They can be set different than what the drawing is drawn in and wouldn't matter if no annotation objects are in the drawing.

 

Doesn't MEASUREMENT just determine to use Imperial or Metric Hatch Patterns and Linetypes, etc.?

 

INSUNITS specifies a drawing units value for automatic scaling of blocks, images, or xrefs inserted or attached to a drawing and has no bearing to what the drawing could actually be drawn in, it could be set to Unitless or whatever even millimeters in an Imperial drawing. Not to mention the value is ignored by annotative blocks.

 

I'm not aware of a sysvar that determines whether a drawing is Meters or millimeters except -DWGUNITS.

 

As for coding, maybe someone will pop in soon and offer some suggestions, but I am just trying to save you some effort by letting you know INSUNITS, CANNOSCLEVALUE are not a good way to determine what units a drawing is drawn in.

 

In our office we have 2 drawing templates (dwt):

 

1. for plans - where units = metres

2. for details - where units = millimetres

 

As such the INSUNITS is set to either 6 (in the plans) or 4 (in the details). I want to use this INSUNITS sysvar to:

 

- determine whether the drawing units are metres or millimetres

 

With that information I can then apply a scaling factor of either 1 or 0.001

 

I'm using CANNOSCALE as a simple visual trigger for the user to pick the drawing scale they want ie 1:100, 1:200, etc

 

Capture7-10-2014-5.46.36%20PM25-02-2015-9.58.26%20PM25-03-2015-8.33.36%20PM21-04-2015-8.56.58%20PM_zps2yy3uehf.png

Link to comment
Share on other sites

  • 1 month later...

DADGAD,

Not to hi-jack this thread, but how do you use MODEMACRO for this? I'm just getting into using this command.

 

Thx,

Link to comment
Share on other sites

Just a few of the variables

 

(defun civ_units ()
(SETQ ANGBASEE (GETVAR "ANGBASE"))
(SETQ ANGDIRR (GETVAR "ANGDIR"))
(SETQ LUNITSS (GETVAR "LUNITS"))
(SETQ LUPRECC (GETVAR "LUPREC"))
(SETQ AUNITSS (GETVAR "AUNITS"))
(SETQ AUPRECC (GETVAR "AUPREC"))
)

Link to comment
Share on other sites

Not to hi-jack this thread, but how do you use MODEMACRO for this? I'm just getting into using this command.

 

Set your MODEMACRO system variable to something like:

$(if,$(getvar,measurement),Metric,Imperial)

Link to comment
Share on other sites

DADGAD,

Not to hi-jack this thread, but how do you use MODEMACRO for this? I'm just getting into using this command.

 

Thx,

 

I typically work in mms, but am occasionally given 3D Models which have been done on Imperial templates, which bugs me.

I use the mode macro as shown in the screenshot, to give me a heads up to such a scenario, just for a wake up call, if everything is as I would expect it to be, then in the lower left corner it just says >> COOL! .

measurement mode macro.jpg

Link to comment
Share on other sites

The code below works exactly as you (thread creator) wished. But I am not sure whether it solves your overall problem as I ain't clear on annotation scale or dim scale concepts.

One thing: You have to manually enter "TEST" at command prompt to set your DIMSCALE accordingly.

(defun C:TEST () ; replace "TEST" to a suitable name
 (if (or (= (getvar "insunits") 4) (= (getvar "insunits") 6))
   (progn
     (if (= (getvar "insunits") 4)
(setvar "dimscale" (/ 1.0 (getvar "CANNOSCALEVALUE")))
(setvar "dimscale" (/ 0.001 (getvar "CANNOSCALEVALUE")))
      )
    )
   (princ "\nYour drawing units need to be set to metres or millimetres.")
  )
 (princ)
)
(princ "\nUse TEST to auotomatically set DIMSCALE") ; replace "TEST" here also ;D
(princ)

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...