-DWGUNITS missing prompts

-DWGUNITS missing prompts

Anonymous
Not applicable
1,644 Views
7 Replies
Message 1 of 8

-DWGUNITS missing prompts

Anonymous
Not applicable

Good Morning AutoDesk Community,

 

I have many custom LISP commands that have been used for years within our company with no issues, until this morning.

 

We have a LISP that runs the following:

 

(command "-dwgunits" 3 2 4 "no" "no" "no")

This would be setting our drawing units to 1:5.

The issue we've been having today is the 3rd prompt for Scaling the drawing has stopped showing up on all of our desktops, which means the 3rd "no" is erroring out the rest of the command. I was able to get the command to prompt me for that 3rd item the first time i ran the command, and never again afterwards. I'm only recieving 2 prompts.

 

Any help would be greatly appreciated.

0 Likes
Accepted solutions (1)
1,645 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable

If it helps, I've tried changing the command to only include 2 "no"s and it then starts asking me 3 prompts during the command.....

0 Likes
Message 3 of 8

Anonymous
Not applicable

Another Update:

 

I believe that i've figured out the change in how this dwgunits handles from autocad 2014 to 2017 (since we just made the jump). It appears that previously it would always ask you if you wanted to change the current objects in the drawing scales upon editing the units. Now it only seems to ask that 3rd prompt when you change from architectural to decimal/etc, so I'm trying to check if it's changing before i run dwgunits, and I'm close but not quite...

 

I'm trying to do the following and i think i have a Syntax error:

 

(if (= (getvar "DIMLUNIT") 4) (command "-dwgunits" 1 4 6 "no" "no") (command "-dwgunits" 1 4 6 "no" "no" "no"))

It's supposed to check if the units are currently architectural and if they are, it only does 2 instances of no, whereas if it is changing, a 3rd no is required for scaling current objects.

 

The metric version i have of this does the following:

 

(if (= (getvar "DIMLUNIT") 2) (command "-dwgunits" 3 2 4 "no" "no") (command "-dwgunits" 3 2 4 "no" "no" "no"))

It appears to be working as intended, and is able to change units just fine...

 

The imperial version appears to have issues that i cant quite figure out, even though to me they look identical. I've done plenty of programming in my past, but never any AutoLISP, so im still learning the syntax.

 

I might be using DIMLUNIT instead of another variable, as it doesnt seem to change to 4 when i run the Imperial function. 

0 Likes
Message 4 of 8

Anonymous
Not applicable

Morning Update:

 

It's almost working, with metric seeming to be fine and imperial to be causing us issues still.

 

Instead of the DIMLUNIT variable, im using LUNITS, which appears to change appropriately for these commands.

 

Metric Version is as follows:

(if (= (getvar "LUNITS") 2) (command "-dwgunits" 3 2 4 "no" "no") (command "-dwgunits" 3 2 4 "no" "no" "no"))

 This appears to be working fine, whereas the imperial version is aborting at the end of the command.

(if (= (getvar "LUNITS") 4) (command "-dwgunits" 1 4 6 "no" "no") (command "-dwgunits" 1 4 6 "no" "no" "no"))
0 Likes
Message 5 of 8

dbroad
Mentor
Mentor

Welcome to the newsgroup.  You posted this

 

(command "-dwgunits" 3 2 4 "no" "no" "no")

This is one command that I have never tried to script because the prompts are contextual to the current situation.  You could use a loop to test whether the command is still prompting.  You could also trap the command inside a vl-catch-all-apply so that any error would not stop your program.

 

The first option is

(command "-dwgunits" 3 2 4 "no")
(while (eq 1 (logand 1 (getvar "CMDACTIVE")))
    (command "no") 
)

The second option is

(vl-catch-all-apply
  '(lambda (x)
    (command "-dwgunits" 3 2 4 "no" "no" "no")
   )
  nil)

The first thing though that you need to ask is "Why are you using those choices?"  No is the worst choice almost always for all fo those answers.  Another question s "Why aren't you using templates rather than scripting this?"  I need this command to convert imperial blocks to millimeter blocks but almost always want the scaling to be done and almost always want the insert units set and other drawings to be scaled upon insertion.  I always measure the objects first to determine which way the prompts should be answered.

Architect, Registered NC, VA, SC, & GA.
Message 6 of 8

Anonymous
Not applicable

Thanks for the reply!

 

I'm well aware we draw things using autocad like it was meant to be used 15 years ago. All of our drawings are done 1:1 and we scale the dimensions to suit our viewport scales, which is what this is meant to do. If I'm drawing a detail i change it to a 1:10 scale using the following routine with another that creates and sets up all the dimension styles:

 

;;------------------------------------------------------------
;;              1:10 drawing set up
;;------------------------------------------------------------

(defun C:units-10 (/ Dcl_Id DlgResponse Toggle1$)
  (setvar "cmdecho" 0)
  (if (= (getvar "LUNITS") 2) (command "-dwgunits" 3 2 4 "no" "no") (command "-dwgunits" 3 2 4 "no" "no" "no"))
  (command "graphscr")
  (command "-units" 2 4 1 2 0.00 "No")
  (setvar "insunits" 0)
  (setvar "insunitsdefsource" 0)
  (setvar "insunitsdeftarget" 0)
  (setvar "textsize" 20)
  (setvar "ltscale" 100)
  (setvar "psltscale" 1)
  (setvar "measurement" 0)
  (if (/= (getvar "tilemode") 0) (setvar "cannoscale" "1:1"))

To be Honest, im much more of a SolidWorks expert, rather than AutoCAD, and I'd like to set up templates similar to how SolidWorks handles them. My issue is finding the time to do so, and having to teach the rest of the office how to use AutoCAD entirely differently. 

 

I will try those methods you've shared, and let you know if they've worked.

 

Thanks once again.

0 Likes
Message 7 of 8

dbroad
Mentor
Mentor

Saving the drawing just after the state of this program as a template (.dwt) file and then using that template when starting a new drawing would be faster and would allow you to do many other things to speed up your work.  Everyone should be drawing full scale and using viewports.  In order to use product data from many sources however, you want to use insunits correctly and want to have things scaled automatically to/from imperial/metric.  Otherwise, you don't have a 1:1 drawing.

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 8 of 8

Anonymous
Not applicable
Accepted solution

Good Evening,

 

I've managed to get the function to work properly without the 2 methods you've chosen.

 

There was an error with another part of the LISP function that was causing an issue, and when it was fixed, along with the new change i proposed with DWGUNITS, i've got my functions behaving properly within AutoCAD 2017.

 

Notepad isn't the greatest IDE...

 

As for our methodology in this LISP routine, One click will set up our dimension styles, insertscales, default text size, LTS and MANY other items related to the scale for a 1:10 drawing(for example). Everything is always drawn at 1:1, but since we do not use annotative dimensions, this allows us to quickly set up everything to detail a drawing to be scaled in a viewport on a layout. We also regularily have drawings at different scales, and when we insert dynamic blocks to incorporate(section markers/etc) they are entered at the correct scale for the drawing.

 

We do have a default template that contains default layers/fonts/linetypes/etc that we use, but because of this routine, we can easily switch through all different scale types for the multiple viewports that might be in a drawing. We don't draw one drawing at a single scale per file, we have multiple drawings, at many scales all within the same file, and set up layouts with appropriate scales. We NEVER have a drawing that shows a US and Metric scale, so there's never any scaling issues between them.

 

I understand there's likely a better way to handle this, but it allows us to be extremely productive in a hybrid fashion. 🙂

Thank you so much for the assistance.

0 Likes