Jump to content

Set different drawing units from acaddoc.lsp


pixel8er

Recommended Posts

Hi all

 

We have different drawing units for the 2 teams in my area. One is millimetres and the other is metres. I know it's not ideal but is unlikely to change.

 

My question is how to handle this in terms of the accaddoc.lsp. Normally I would have a line of code to set the units on drawing open like:

 

;; Sets insunits to millimetres
(setvar "INSUNITSDEFSOURCE" 4)
(setvar "INSUNITSDEFTARGET" 4)

 

...but with 2 units to set I need a method to be able to determine what team the drawing is from and therefore what units should be applied. The drawings from both teams are in the same location on the server.

 

I guess one way to accommodate this is to have completely separate support files for each team and point the autocad support file search paths to the relevant support files. Any other ways you can suggest?

 

Thanks

Paul

Link to comment
Share on other sites

Hi,

 

If you separate the files into two different folders as per their units , then you would be able to determine the units of each file by its directory name.

 

Unfortunately that's not an option. The drawings need to stay in the same location on the server

Link to comment
Share on other sites

How you determine what team is what is up to you, but once you do, you can simply do something like this.

 


(cond ((eq team "1")
      (setvar "INSUNITSDEFSOURCE" 4)
      (setvar "INSUNITSDEFTARGET" 4)
     )
     ((eq team "2")
      (setvar "INSUNITSDEFSOURCE" 6)
      (setvar "INSUNITSDEFTARGET" 6)
     )
)

Link to comment
Share on other sites

Test the login name against a list of known login names for the members of each of your teams? e.g.:

(mapcar 'setvar '("INSUNITSDEFSOURCE" "INSUNITSDEFTARGET")
   (if (member (strcase (getvar 'loginname)) '("USER1" "USER2" "USER3"))
      '(4 4)
      '(6 6)
   )
)

Link to comment
Share on other sites

Tharwat - I'm not sure what you mean. I probably haven't explained my question very well.

 

rkmcswain - That's really the crux of my problem...I'm not sure how to determine (programatically) which team the drawings are from.

 

Some more info. The project folders are distributed randomly in term of mm and metres:

 

R:\Projects\PR0001 - this contains mm drawings

R:\Projects\PR0002 - this contains metres drawings

R:\Projects\PR0003 - this contains mm drawings

R:\Projects\PR0004 - this contains mm drawings

R:\Projects\PR0005 - this contains metres drawings

R:\Projects\PR0006 - this contains mm drawings

R:\Projects\PR0007 - this contains mm drawings

R:\Projects\PR0008 - this contains mm drawings

R:\Projects\PR0009 - this contains mm drawings

R:\Projects\PR0010 - this contains mm drawings

R:\Projects\PR0011 - this contains metres drawings

R:\Projects\PR0012 - this contains metres drawings

etc

Link to comment
Share on other sites

Test the login name against a list of known login names for the members of each of your teams

 

Great idea Lee. Though possibly not viable with people leaving and new people joining. But gives me an idea...possibly IT have assigned a unique group for each team - I'll check tomorrow

Link to comment
Share on other sites

Hi..

 

Forgive me for chipping in, but Paul, Autocad has a unit setting for drawings, which has nothing to do with the insunitdeftarget/insunitdefsource variables. These 2 variables are in fact the "insertion scale" default settings (user preference tab of the option menu). They only affect how UNITLESS blocks are handled when inserted in the current drawing. (unless your blocks are all unitless?)

 

In a drawing, the units are stored in a far, far place, and as far as I know, the only way you can access is with the command "-dwgunits". (and the unit it is not in any variable)

Entering "-dwgunits" will trigger a series of questions, and amongst them 2 very important ones.

 

Command: -DWGUNITS

Drawing units:

1. Inches

2. Feet

3. Millimeters

4. Centimeters

5. Decimeters

6. Meters

Unit for length :

 

Drawing unit display formats:

1. Scientific

2. Decimal

3. Engineering

4. Architectural

5. Fractional

Linear display format :

 

Architectural linear display precision formats:

0. 1"

1. 1/2"

2. 1/4"

3. 1/8"

4. 1/16"

5. 1/32"

6. 1/64"

7. 1/128"

8. 1/256"

Linear display precision :

 

Scale objects from other drawings upon insert? [Yes/No] :

 

Match INSUNITS to drawing units? [Yes/No] :

As you can see there can be a discripency between the insunits variable and the real (which can lead to unwanted results and behaviors). If the -dwgunits are always set correctly, "Scale objects from other drawings upon insert?" as well as "Match INSUNITS to drawing units?" are set to "YES", then blocks and xref inserted will always have the correct "factor", and will automatically appear at the correct scale without needing to adjust it.

 

In the 1rst image, my dwg is in mm, and I insert a mm xref (see the block unit to mm, factor 1?).

image.png

(I've changed the units to inch (2nd image), and as you can see, CAD sees that my actual dwg is in inches, and the xref i insert is in mm, so it has a factor of 0.0394 automatically)

image.png

 

The good part is that any block/xref that has an automatical "factor" won't have its scale affected, so scale always stays at 1

image.png

 

That being said.. if every drawing has units setted correctly, and the insunits variable is always correct (by using -dwgunits prompt and always answering "Match INSUNITS to drawing units?" by "YES"), THEN you should not have any other variables to change, unless if you have unitless blocks (only these require the insunitdeftarget/insunitdefsource variables). You then have 2 choices:

you could use the insunits (which is stored in the drawing, and theorethically always setted correctly by the "-dwgunits" command)

(mapcar '(lambda (x) (setvar x (getvar 'insunits))) '("INSUNITSDEFSOURCE" "INSUNITSDEFTARGET"))

or even simpler, edit every unitless block with the block editor and set the units correctly. That way the factor will always be correct right away, and all scales will be 1.

 

Cheers,

Jef!

Link to comment
Share on other sites

Simple defun to change units etc. Why would you just not have two dwt with them set to mm and M so no need for the acaddoc.lsp to change.

 

(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"))

(SETVAR "LUNITS" 2)
(SETVAR "ANGBASE" 0.0)
(SETVAR "ANGDIR" 0)
(SETVAR "LUPREC" 0)
(SETVAR "AUNITS" 0)
(SETVAR "AUPREC" 0)
)

(defun old_civ_units ()
(SETVAR "LUNITS" lunitss)
(SETVAR "ANGBASE" angbasee)
(SETVAR "ANGDIR" angdirr)
(SETVAR "LUPREC" luprecc)
(SETVAR "AUNITS" aunitss)
(SETVAR "AUPREC" auprecc)
)

  • Thanks 1
Link to comment
Share on other sites

Jef!

Thanks for your indepth reply. I probably didn't really explain myself very well. I'm hoping to find a way to get my acaddoc.lsp to detect which team the user is in and apply templates, settings, etc based on that.

The units (UN) setting directly affects the insunits variable so I need to determine which user is in which team so that the correct scaling factor can be applied.

I want to pre-set all this on drawing open so the user is working on the correct template, units, etc.

 

BIGAL

I certainly will have 2 templates - 1 for mm and 1 for metres. I want to get the acaddoc.lsp code to:

 

1. Detect which team the user is from. I'm hoping to get IT to set one logon group for everyone in the metres team and another logon group for everyone in the mm team.

2. Set the units relevant to that particular team

3. Set the Support File Search Path relevant to that particular team

4. Set the Template Settings paths relevant to that particular team

Link to comment
Share on other sites

Test the login name against a list of known login names for the members of each of your teams? e.g.:

(mapcar 'setvar '("INSUNITSDEFSOURCE" "INSUNITSDEFTARGET")
   (if (member (strcase (getvar 'loginname)) '("USER1" "USER2" "USER3"))
      '(4 4)
      '(6 6)
   )
)

 

Hi Lee

Thanks again for your reply. Thinking further on this:

 

1. Rather than using the individual logon names is it more efficient to put the users in 2 logon groups? I checked with IT and currently all users are under the one logon group.

 

2. What code would change to use the logon group rather than the login names?

 

3. How long would that take to create the 2 logon groups for 50 users? How long to maintain as users come and go?

 

4. How much time would this add to the drawing opening?

 

Thanks

Paul

Link to comment
Share on other sites

Hi Paul,

 

 

Just wondering if the two groups are set up using a different AutoCAD profile for each discipline?

If so, your distinguishing between them could be as simple as (getvar "cprofile").

Link to comment
Share on other sites

Hi Paul,

 

 

Just wondering if the two groups are set up using a different AutoCAD profile for each discipline?

If so, your distinguishing between them could be as simple as (getvar "cprofile").

 

Hi Clint. They aren't yet - but that could work!

 

Maybe a better way to handle this is with 2 different profiles - 1 for mm and 1 for metres. Then have a custom desktop shortcut pointing to the relevant profile. Then just need to work out how to deploy to the users?

Link to comment
Share on other sites

  • 4 years later...

I'm looking to report the units of a drawing (from the -dwgunits command or the EDITDRAWINGSETTINGS command in Civil 3D) to a text file.   Is there a LISP, VLISP, or system variable that will report the current units of a drawing ?

 

i.e., report the values above either as text or a numerical integer or bitcode ?  We'd like to run it on batches of drawings to create a spreadsheet of current settings for review...

 

Drawing units:

1. Inches

2. Feet

3. Millimeters

4. Centimeters

5. Decimeters

6. Meters

Unit for length :

Link to comment
Share on other sites

On 1/18/2016 at 5:27 PM, BIGAL said:

Simple defun to change units etc. Why would you just not have two dwt with them set to mm and M so no need for the acaddoc.lsp to change.

A few templates already set up can really reduce drawing time and eliminate needing to make modifications like Dimension Styles and linetypes.

We use a variety of templates for whatever workflow the job requires.

Ctrl+Home in AutoCAD takes you to the Start page to browse them or add the ones you use to a custom panel .

image.thumb.png.43f1fdce9800ed1390c0f42e41f738bb.png

Link to comment
Share on other sites

Go look at my post Jan 2019 there is the answer. The variables will return a number you will need to set the number =

aunits = 3 = radians. 

Lunits = 2 = decimal

 

 

Type setvar ? * and you can see all variables. turn on LOGFILE and can make a txt file open it change a variable and then do setvar ? * and compare make sure do logfileoff. 

Edited by BIGAL
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...