pixel8er Posted April 18, 2015 Share Posted April 18, 2015 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 Quote Link to comment Share on other sites More sharing options...
Dadgad Posted April 18, 2015 Share Posted April 18, 2015 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. Quote Link to comment Share on other sites More sharing options...
pixel8er Posted April 18, 2015 Author Share Posted April 18, 2015 (edited) 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 April 19, 2015 by pixel8er Quote Link to comment Share on other sites More sharing options...
pixel8er Posted April 19, 2015 Author Share Posted April 19, 2015 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. Quote Link to comment Share on other sites More sharing options...
SLW210 Posted April 20, 2015 Share Posted April 20, 2015 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. Quote Link to comment Share on other sites More sharing options...
pixel8er Posted April 21, 2015 Author Share Posted April 21, 2015 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 Quote Link to comment Share on other sites More sharing options...
GISdude Posted May 22, 2015 Share Posted May 22, 2015 DADGAD, Not to hi-jack this thread, but how do you use MODEMACRO for this? I'm just getting into using this command. Thx, Quote Link to comment Share on other sites More sharing options...
BIGAL Posted May 23, 2015 Share Posted May 23, 2015 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")) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 23, 2015 Share Posted May 23, 2015 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) Quote Link to comment Share on other sites More sharing options...
Dadgad Posted May 23, 2015 Share Posted May 23, 2015 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! . Quote Link to comment Share on other sites More sharing options...
Vignatus Posted May 24, 2015 Share Posted May 24, 2015 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) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.