Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Need to display drawing units in status bar.

16 REPLIES 16
Reply
Message 1 of 17
lsaapedd
688 Views, 16 Replies

Need to display drawing units in status bar.

Does anyone know how to use modemacro to place the current drawing units (Arch, Decimal, etc...) on the status line? If it is possible, I would greatly appreciate the info.

Thanks,

Jerry
16 REPLIES 16
Message 2 of 17
Kent1Cooper
in reply to: lsaapedd

We have this in acad.lsp, though I think there are other places it can go:

{code}
(defun S::STARTUP ()
(setvar "modemacro"
(strcat
"DF:$(getvar,useri1) "
"$(if,$(getvar,snapmode), Snap:)"
"$(if,$(getvar,snapmode),$(rtos,$(getvar,snapunit)) )"
(cond
((= (getvar 'lunits) 1) "Scientific")
((= (getvar 'lunits) 2) "Decimal")
((= (getvar 'lunits) 3) "Engineering")
((= (getvar 'lunits) 4) "Architectural")
((= (getvar 'lunits) 5) "Fractional")
); end cond
)
)
)
{code}

I just added the (cond) portion to test it, and it does what you're after [now I'll probably take it out again, since we virtually always use only one of those]. You may already have something like this with other things in place of the other elements in ours. If you have nothing else to put there on the status line, you could probably get away with just:

{code}
(defun S::STARTUP ()
(setvar "modemacro"
(cond
((= (getvar 'lunits) 1) "Scientific")
((= (getvar 'lunits) 2) "Decimal")
((= (getvar 'lunits) 3) "Engineering")
((= (getvar 'lunits) 4) "Architectural")
((= (getvar 'lunits) 5) "Fractional")
); end cond
)
)
{code}

****GRAIN OF SALT: I find it doesn't update the units type when I change it, the way the display of snap value updates when I change that. It doesn't even update it when opening another drawing in another type of units, but sticks with the type in the first drawing opened when AutoCAD is started. I assume that has something to do with the Lisp vs. Diesel language. I'm not fluent enough in Diesel, and don't even know whether it has a (cond) or similar function. If not, maybe it could be done with a series of (if)'s instead.****

--
Kent Cooper


lsaapedd wrote...
Does anyone know how to use modemacro to place the current drawing units (Arch, Decimal, etc...) on the status line?.... Edited by: Kent1Cooper on May 19, 2010 3:43 PM
[added Grain of Salt paragraph]
Kent Cooper, AIA
Message 3 of 17
Anonymous
in reply to: lsaapedd

Your (cond) doesn't work.

In it, you're passing a quoted symbol to (getvar).

(getvar) requires strings, not symbols.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2011

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6394046@discussion.autodesk.com...
We have this in acad.lsp, though I think there are other places it can go:

{code}
(defun S::STARTUP ()
(setvar "modemacro"
(strcat
"DF:$(getvar,useri1) "
"$(if,$(getvar,snapmode), Snap:)"
"$(if,$(getvar,snapmode),$(rtos,$(getvar,snapunit)) )"
(cond
((= (getvar 'lunits) 1) "Scientific")
((= (getvar 'lunits) 2) "Decimal")
((= (getvar 'lunits) 3) "Engineering")
((= (getvar 'lunits) 4) "Architectural")
((= (getvar 'lunits) 5) "Fractional")
); end cond
)
)
)
{code}

I just added the (cond) portion to test it, and it does what you're after [now
I'll probably take it out again, since we virtually always use only one of
those]. You may already have something like this with other things in place of
the other elements in ours. If you have nothing else to put there on the status
line, you could probably get away with just:

{code}
(defun S::STARTUP ()
(setvar "modemacro"
(cond
((= (getvar 'lunits) 1) "Scientific")
((= (getvar 'lunits) 2) "Decimal")
((= (getvar 'lunits) 3) "Engineering")
((= (getvar 'lunits) 4) "Architectural")
((= (getvar 'lunits) 5) "Fractional")
); end cond
)
)
{code}

****GRAIN OF SALT: I find it doesn't update the units type when I change it,
the way the display of snap value updates when I change that. It doesn't even
update it when opening another drawing in another type of units, but sticks with
the type in the first drawing opened when AutoCAD is started. I assume that has
something to do with the Lisp vs. Diesel language. I'm not fluent enough in
Diesel, and don't even know whether it has a (cond) or similar function. If
not, maybe it could be done with a series of (if)'s instead.****

--
Kent Cooper


lsaapedd wrote...
Does anyone know how to use modemacro to place the current drawing units (Arch,
Decimal, etc...) on the status line?....

Edited by: Kent1Cooper on May 19, 2010 3:43 PM
[added Grain of Salt paragraph]
Message 4 of 17
Anonymous
in reply to: lsaapedd

As Kent says, it won't update when changing from one drawing to another (with
different units). The way around this is to create a modemacro that uses
USERS1 (or any UserS? variable that is not being used). The modemacro need be
created just once (acad.lsp). Then assign USERS1 to the desired units string
in each drawings (acaddoc.lsp, or wherever you are doing this):

Do once:
(setvar "modemacro" "Units: $(getvar,users1)")

; Do each drawing:
(setvar "users1"
(cond
((= (getvar 'lunits) 1) "Scientific")
((= (getvar 'lunits) 2) "Decimal")
((= (getvar 'lunits) 3) "Engineering")
((= (getvar 'lunits) 4) "Architectural")
((= (getvar 'lunits) 5) "Fractional")
); end cond
)

Also, if you have a routine to change units, do the same as part of that
routine (or create a reactor to monitor users1).

Ken Krupa
Autodesk Authorized Developer
Krupa CADD Solutions
www.krupacadd.com
Message 5 of 17
Kent1Cooper
in reply to: lsaapedd

Not true [except for the middle sentence] -- the AutoLISP Reference itself uses (getvar 'FILLETRAD) as its one example of how to use the function. For whatever reason, they use the single-quote-only-at-the-beginning variety there, and the double-quotes-at-both-ends variety in the example for (setvar) [with the same System Variable], but either way works with both functions. This has come up before, and others have been unaware of it. And, it *does* work for me, to put the units variety name in the status line, except for the grain-of-salt problem already described.

--
Kent Cooper


Tony Tanzillo wrote...

Your (cond) doesn't work.

In it, you're passing a quoted symbol to (getvar).

(getvar) requires strings, not symbols.
Kent Cooper, AIA
Message 6 of 17
Anonymous
in reply to: lsaapedd

I think this used to be true but changed some time ago.

Command: (getvar 'lunits)
4

(R2004)

Tony Tanzillo wrote:
> Your (cond) doesn't work.
>
> In it, you're passing a quoted symbol to (getvar).
>
> (getvar) requires strings, not symbols.
>
Message 7 of 17
Kent1Cooper
in reply to: lsaapedd

Well, it *was* solved by using a series of Diesel (if) functions, rather than a Lisp (cond) function. This *does* update when you change the Units type within a drawing, or open a different drawing using a different type of Units, and does not require a function to be run in every drawing, or a reactor to respond to changes in Units, or the use of a USERS? System Variable, or anything else like that:

{code}
(defun S::STARTUP ()
(setvar "modemacro"
(strcat
"DF:$(getvar,useri1) "
"$(if,$(getvar,snapmode), Snap:)"
"$(if,$(getvar,snapmode),$(rtos,$(getvar,snapunit)) )"
"$(if,$(=,$(getvar,lunits),1), Scientific)"
"$(if,$(=,$(getvar,lunits),2), Decimal)"
"$(if,$(=,$(getvar,lunits),3), Engineering)"
"$(if,$(=,$(getvar,lunits),4), Architectural)"
"$(if,$(=,$(getvar,lunits),5), Fractional)"
)
)
)
{code}

That includes our other Status-line stuff about our Drawing Factor and Snap settings. For just the Units type, you can do this:

{code}
(defun S::STARTUP ()
(setvar "modemacro"
(strcat
"$(if,$(=,$(getvar,lunits),1),Scientific)"
"$(if,$(=,$(getvar,lunits),2),Decimal)"
"$(if,$(=,$(getvar,lunits),3),Engineering)"
"$(if,$(=,$(getvar,lunits),4),Architectural)"
"$(if,$(=,$(getvar,lunits),5),Fractional)"
)
)
)
{code}

--
Kent Cooper


Kent Cooper wrote...
****GRAIN OF SALT: I find it doesn't update the units type when I change it.... It doesn't even update it when opening another drawing in another type of units, but sticks with the type in the first drawing opened when AutoCAD is started. I assume that has something to do with the Lisp vs. Diesel language. ....
Kent Cooper, AIA
Message 8 of 17
Anonymous
in reply to: lsaapedd

I think this new behavior has been adopted since the blackboard variables
were introduced, for some kind of compatibility I assume.


--
The difference between truth and fiction is that fiction has to make sense.



"Tony Tanzillo" a écrit dans le message de
news: 6394124@discussion.autodesk.com...
Your (cond) doesn't work.

In it, you're passing a quoted symbol to (getvar).

(getvar) requires strings, not symbols.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2011

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6394046@discussion.autodesk.com...
We have this in acad.lsp, though I think there are other places it can go:

{code}
(defun S::STARTUP ()
(setvar "modemacro"
(strcat
"DF:$(getvar,useri1) "
"$(if,$(getvar,snapmode), Snap:)"
"$(if,$(getvar,snapmode),$(rtos,$(getvar,snapunit)) )"
(cond
((= (getvar 'lunits) 1) "Scientific")
((= (getvar 'lunits) 2) "Decimal")
((= (getvar 'lunits) 3) "Engineering")
((= (getvar 'lunits) 4) "Architectural")
((= (getvar 'lunits) 5) "Fractional")
); end cond
)
)
)
{code}

I just added the (cond) portion to test it, and it does what you're after
[now
I'll probably take it out again, since we virtually always use only one of
those]. You may already have something like this with other things in place
of
the other elements in ours. If you have nothing else to put there on the
status
line, you could probably get away with just:

{code}
(defun S::STARTUP ()
(setvar "modemacro"
(cond
((= (getvar 'lunits) 1) "Scientific")
((= (getvar 'lunits) 2) "Decimal")
((= (getvar 'lunits) 3) "Engineering")
((= (getvar 'lunits) 4) "Architectural")
((= (getvar 'lunits) 5) "Fractional")
); end cond
)
)
{code}

****GRAIN OF SALT: I find it doesn't update the units type when I change
it,
the way the display of snap value updates when I change that. It doesn't
even
update it when opening another drawing in another type of units, but sticks
with
the type in the first drawing opened when AutoCAD is started. I assume that
has
something to do with the Lisp vs. Diesel language. I'm not fluent enough in
Diesel, and don't even know whether it has a (cond) or similar function. If
not, maybe it could be done with a series of (if)'s instead.****

--
Kent Cooper


lsaapedd wrote...
Does anyone know how to use modemacro to place the current drawing units
(Arch,
Decimal, etc...) on the status line?....

Edited by: Kent1Cooper on May 19, 2010 3:43 PM
[added Grain of Salt paragraph]
Message 9 of 17
Anonymous
in reply to: lsaapedd

Oops - you're right, and I beg your pardon Kent. I was thinking of some past
situation where I needed to use a userS variable. Sorry for the
misinformation. <|:-0

Kent1Cooper wrote:
> Well, it *was* solved by using a series of Diesel (if) functions, rather than a Lisp (cond) function. This *does* update when you change the Units type within a drawing, or open a different drawing using a different type of Units, and does not require a function to be run in every drawing, or a reactor to respond to changes in Units, or anything else like that:
>
> {code}
> (defun S::STARTUP ()
> (setvar "modemacro"
> (strcat
> "DF:$(getvar,useri1) "
> "$(if,$(getvar,snapmode), Snap:)"
> "$(if,$(getvar,snapmode),$(rtos,$(getvar,snapunit)) )"
> "$(if,$(=,$(getvar,lunits),1), Scientific)"
> "$(if,$(=,$(getvar,lunits),2), Decimal)"
> "$(if,$(=,$(getvar,lunits),3), Engineering)"
> "$(if,$(=,$(getvar,lunits),4), Architectural)"
> "$(if,$(=,$(getvar,lunits),5), Fractional)"
> )
> )
> )
> {code}
>
> That includes our other Status-line stuff about our Drawing Factor and Snap settings. For just the Units type, you can do this:
>
> {code}
> (defun S::STARTUP ()
> (setvar "modemacro"
> (strcat
> "$(if,$(=,$(getvar,lunits),1),Scientific)"
> "$(if,$(=,$(getvar,lunits),2),Decimal)"
> "$(if,$(=,$(getvar,lunits),3),Engineering)"
> "$(if,$(=,$(getvar,lunits),4),Architectural)"
> "$(if,$(=,$(getvar,lunits),5),Fractional)"
> )
> )
> )
> {code}
>
> --
> Kent Cooper
>
>
> Kent Cooper wrote...
> ****GRAIN OF SALT: I find it doesn't update the units type when I change it.... It doesn't even update it when opening another drawing in another type of units, but sticks with the type in the first drawing opened when AutoCAD is started. I assume that has something to do with the Lisp vs. Diesel language. ....
Message 10 of 17
Anonymous
in reply to: lsaapedd

Ok, Now that I tried it, I see they've changed it to take symbols,
but what releases does that work in?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2011

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6394136@discussion.autodesk.com...
Not true [except for the middle sentence] -- the AutoLISP Reference itself uses
(getvar 'FILLETRAD) as its one example of how to use the function. For whatever
reason, they use the single-quote-only-at-the-beginning variety there, and the
double-quotes-at-both-ends variety in the example for (setvar) [with the same
System Variable], but either way works with both functions. This has come up
before, and others have been unaware of it. And, it *does* work for me, to put
the units variety name in the status line, except for the grain-of-salt problem
already described.

--
Kent Cooper


Tony Tanzillo wrote...

Your (cond) doesn't work.

In it, you're passing a quoted symbol to (getvar).

(getvar) requires strings, not symbols.
Message 11 of 17
Anonymous
in reply to: lsaapedd

Hi Tony,

It works on 2006.

It's the oldest that I have on my machine, but as I said, I think that this
goes back to the times when blackboard variables were implemented.

Regards

--
The difference between truth and fiction is that fiction has to make sense.



"Tony Tanzillo" a écrit dans le message de
news: 6394817@discussion.autodesk.com...
Ok, Now that I tried it, I see they've changed it to take symbols,
but what releases does that work in?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2011

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6394136@discussion.autodesk.com...
Not true [except for the middle sentence] -- the AutoLISP Reference itself
uses
(getvar 'FILLETRAD) as its one example of how to use the function. For
whatever
reason, they use the single-quote-only-at-the-beginning variety there, and
the
double-quotes-at-both-ends variety in the example for (setvar) [with the
same
System Variable], but either way works with both functions. This has come
up
before, and others have been unaware of it. And, it *does* work for me, to
put
the units variety name in the status line, except for the grain-of-salt
problem
already described.

--
Kent Cooper


Tony Tanzillo wrote...

Your (cond) doesn't work.

In it, you're passing a quoted symbol to (getvar).

(getvar) requires strings, not symbols.
Message 12 of 17
lsaapedd
in reply to: lsaapedd

I want to thank all the responders. I now have the type of units a drawing is set to in my Status line, and it changes if I change the setting.

Again, Thanks!

Jerry
Message 13 of 17
scot-65
in reply to: lsaapedd

FYI
MODEMACRO (used to be?) limited to 255 characters.
When you run out of characters, that's it. No more to display.

Alternative is to create a new pull-down and directly paste
the diesel code between the "[ ]".
See my screenshot.

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


Message 14 of 17
Anonymous
in reply to: lsaapedd

If you are interested in a way to escape the 255 char limitation, this
thread suggests a way you might be able to accomplish that:

http://discussion.autodesk.com/forums/thread.jspa?threadID=670578&tstart=3555

Regards,
David Kozina


wrote in message news:6394903@discussion.autodesk.com...
FYI
MODEMACRO (used to be?) limited to 255 characters.
When you run out of characters, that's it. No more to display.

Alternative is to create a new pull-down and directly paste
the diesel code between the "[ ]".
See my screenshot.
Message 15 of 17
Anonymous
in reply to: lsaapedd

Works in R2000i, not in R14

Tony Tanzillo wrote:
> Ok, Now that I tried it, I see they've changed it to take symbols,
> but what releases does that work in?
>
Message 16 of 17
Anonymous
in reply to: lsaapedd

I think that this just proves my assumption, because I believe that Visual
LISP was implemented in AutoCAD 2000 if I am recalling this correctly.

--
The difference between truth and fiction is that fiction has to make sense.



"Ken Krupa" a écrit dans le message de
news: 6395425@discussion.autodesk.com...
Works in R2000i, not in R14

Tony Tanzillo wrote:
> Ok, Now that I tried it, I see they've changed it to take symbols,
> but what releases does that work in?
>
Message 17 of 17
Anonymous
in reply to: lsaapedd

That's right.

Some Buddy wrote:
> I think that this just proves my assumption, because I believe that Visual
> LISP was implemented in AutoCAD 2000 if I am recalling this correctly.
>

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost