TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: andrew_nao on November 22, 2011, 11:07:14 AM

Title: how can i display dimscale with active dwg
Post by: andrew_nao on November 22, 2011, 11:07:14 AM
I have the following code in my acaddoc that displays the dimscale of the dwg. (mode macro)
however if i have multiple dwgs opened, it displays the same dimscale across all the dwgs of the last opened dwg.

anyone have any ideas on how to make it so it displays the right dimscale depending on what dwg is active?
I imaging by using vlisp would do it but im not sure how to impliment it

any help or pointers is appreciated

Code: [Select]
(setq App (vlax-Get-Acad-Object)
Doc (vla-Get-ActiveDocument App)
)

Code: [Select]
(setq modmac (atoi (rtos (getvar "dimscale"))))

(IF (= modmac 1) (setvar "modemacro" "...DWG DIMSCALE IS... 12 = 1' - 0"))
(IF (= modmac 2) (setvar "modemacro" "...DWG DIMSCALE IS... 6 = 1' - 0"))
(IF (= modmac 3) (setvar "modemacro" "...DWG DIMSCALE IS... 4 = 1' - 0"))
(IF (= modmac 4) (setvar "modemacro" "...DWG DIMSCALE IS... 3 = 1' - 0"))
(IF (= modmac 6) (setvar "modemacro" "...DWG DIMSCALE IS... 2 = 1' - 0"))
(IF (= modmac 8) (setvar "modemacro" "...DWG DIMSCALE IS... 1 1/2 = 1' - 0"))
(IF (= modmac 12) (setvar "modemacro" "...DWG DIMSCALE IS... 1 = 1' - 0"))
(IF (= modmac 16) (setvar "modemacro" "...DWG DIMSCALE IS... 3/4 = 1' - 0"))
(IF (= modmac 24) (setvar "modemacro" "...DWG DIMSCALE IS... 1/2 = 1' - 0"))
(IF (= modmac 32) (setvar "modemacro" "...DWG DIMSCALE IS... 3/8 = 1' - 0"))
(IF (= modmac 48) (setvar "modemacro" "...DWG DIMSCALE IS... 1/4 = 1' - 0"))
(IF (= modmac 64) (setvar "modemacro" "...DWG DIMSCALE IS... 3/16 = 1' - 0"))
(IF (= modmac 96) (setvar "modemacro" "...DWG DIMSCALE IS... 1/8 = 1' - 0"))
(IF (= modmac 128) (setvar "modemacro" "...DWG DIMSCALE IS... 3/32 = 1' - 0"))
Title: Re: how can i display dimscale with active dwg
Post by: alanjt on November 22, 2011, 12:13:11 PM
Your setting your modemacro with a string rather than an equation.

Code: [Select]
(setvar 'MODEMACRO (blah blah))
Here's mine:

Code: [Select]
                 ("modemacro"
                  "$(getvar,clayer)  ($(edtime, $(getvar,date),H:MMam/pm) - $(edtime,$(getvar,date),M.DD.YY))  Textsize: $(getvar,textsize) $(if, $(!=, $(getvar,viewtwist), 0), Viewtwist: $(angtos, $(getvar,viewtwist) [, 0, 2]) , ) AnnoScale: $(getvar,cannoscale)  Dimscale: $(getvar,dimscale) $(if, $(!=, $(getvar,filletrad), 0), FilletRad: $(getvar,filletrad), ) $(if, $(=, $(getvar,worlducs), 1),*WCS* ,*NON-WCS*) "
                 )
Title: Re: how can i display dimscale with active dwg
Post by: andrew_nao on November 22, 2011, 02:23:00 PM
Your setting your modemacro with a string rather than an equation.

Code: [Select]
(setvar 'MODEMACRO (blah blah))
Here's mine:

Code: [Select]
                 ("modemacro"
                  "$(getvar,clayer)  ($(edtime, $(getvar,date),H:MMam/pm) - $(edtime,$(getvar,date),M.DD.YY))  Textsize: $(getvar,textsize) $(if, $(!=, $(getvar,viewtwist), 0), Viewtwist: $(angtos, $(getvar,viewtwist) [, 0, 2]) , ) AnnoScale: $(getvar,cannoscale)  Dimscale: $(getvar,dimscale) $(if, $(!=, $(getvar,filletrad), 0), FilletRad: $(getvar,filletrad), ) $(if, $(=, $(getvar,worlducs), 1),*WCS* ,*NON-WCS*) "
                 )

I tried to load yours via lisp and i get bad function error
when i enter it manually (copy n paste) it displays the code and not the date, time or anything that its supposed to
Title: Re: how can i display dimscale with active dwg
Post by: alanjt on November 22, 2011, 02:25:10 PM
Your setting your modemacro with a string rather than an equation.

Code: [Select]
(setvar 'MODEMACRO (blah blah))
Here's mine:

Code: [Select]
                 ("modemacro"
                  "$(getvar,clayer)  ($(edtime, $(getvar,date),H:MMam/pm) - $(edtime,$(getvar,date),M.DD.YY))  Textsize: $(getvar,textsize) $(if, $(!=, $(getvar,viewtwist), 0), Viewtwist: $(angtos, $(getvar,viewtwist) [, 0, 2]) , ) AnnoScale: $(getvar,cannoscale)  Dimscale: $(getvar,dimscale) $(if, $(!=, $(getvar,filletrad), 0), FilletRad: $(getvar,filletrad), ) $(if, $(=, $(getvar,worlducs), 1),*WCS* ,*NON-WCS*) "
                 )

I tried to load yours and i get bad function error
that's because you have to apply a function to the list. This is one variable in a list of system variables feed to a foreach statement that uses vl-catch-all-apply to apply the variable change.

Just add setvar as the first item in the list.

eg.
Code: [Select]
(setvar "modemacro" blah blah)
Title: Re: how can i display dimscale with active dwg
Post by: alanjt on November 22, 2011, 02:31:39 PM

It wasn't really given so you could use it, but more so you could look through the bit of code and see how modemacro is being evaluated vs. yours.
Title: Re: how can i display dimscale with active dwg
Post by: Lee Mac on November 22, 2011, 05:53:52 PM
http://docs.autodesk.com/ACD/2011/ENU/filesACG/WS73099cc142f4875513fb5cd10c4aa30d6b-7b56.htm (http://docs.autodesk.com/ACD/2011/ENU/filesACG/WS73099cc142f4875513fb5cd10c4aa30d6b-7b56.htm)

Specifically:

http://docs.autodesk.com/ACD/2011/ENU/filesACG/WS73099cc142f4875513fb5cd10c4aa30d6b-7b50.htm (http://docs.autodesk.com/ACD/2011/ENU/filesACG/WS73099cc142f4875513fb5cd10c4aa30d6b-7b50.htm)
Title: Re: how can i display dimscale with active dwg
Post by: andrew_nao on November 23, 2011, 09:45:11 AM

It wasn't really given so you could use it, but more so you could look through the bit of code and see how modemacro is being evaluated vs. yours.


i was trying to see how it worked, cause i wasnt understanding some of it.

yours does the same thing, when you open a dwg, its displays that dwgs info if you goto a dwg you have open (hidden in the background) it displays the info from the dwg you last opened and not the info for the current active dwg.


Title: Re: how can i display dimscale with active dwg
Post by: alanjt on November 23, 2011, 10:52:41 AM

It wasn't really given so you could use it, but more so you could look through the bit of code and see how modemacro is being evaluated vs. yours.


i was trying to see how it worked, cause i wasnt understanding some of it.

yours does the same thing, when you open a dwg, its displays that dwgs info if you goto a dwg you have open (hidden in the background) it displays the info from the dwg you last opened and not the info for the current active dwg.
It should - works on my machine...


Title: Re: how can i display dimscale with active dwg
Post by: alanjt on November 23, 2011, 11:04:49 AM
Sorry for the crappy delay in the video, I had 2009 open at moment and it just doesn't do well with jumping between active drawings.
Title: Re: how can i display dimscale with active dwg
Post by: cmwade77 on November 23, 2011, 03:12:19 PM
I agree, it works, but it might be some issues with some extra returns and such, here is exactly how I have it:
Code: [Select]
(setvar "modemacro" "$(getvar,clayer)  ($(edtime, $(getvar,date),H:MMam/pm) - $(edtime,$(getvar,date),M.DD.YY))  Textsize: $(getvar,textsize) $(if, $(!=, $(getvar,viewtwist), 0), Viewtwist: $(angtos, $(getvar,viewtwist) [, 0, 2]) , ) AnnoScale: $(getvar,cannoscale)  Dimscale: $(getvar,dimscale) $(if, $(!=, $(getvar,filletrad), 0), FilletRad: $(getvar,filletrad), ) $(if, $(=, $(getvar,worlducs), 1),*WCS* ,*NON-WCS*) ")
Title: Re: how can i display dimscale with active dwg
Post by: alanjt on November 23, 2011, 03:18:08 PM
I agree, it works, but it might be some issues with some extra returns and such, here is exactly how I have it:
Code: [Select]
(setvar "modemacro" "$(getvar,clayer)  ($(edtime, $(getvar,date),H:MMam/pm) - $(edtime,$(getvar,date),M.DD.YY))  Textsize: $(getvar,textsize) $(if, $(!=, $(getvar,viewtwist), 0), Viewtwist: $(angtos, $(getvar,viewtwist) [, 0, 2]) , ) AnnoScale: $(getvar,cannoscale)  Dimscale: $(getvar,dimscale) $(if, $(!=, $(getvar,filletrad), 0), FilletRad: $(getvar,filletrad), ) $(if, $(=, $(getvar,worlducs), 1),*WCS* ,*NON-WCS*) ")
possible, but I've been using that since I wrote it for 2006 and never had a problem.
Title: Re: how can i display dimscale with active dwg
Post by: andrew_nao on November 29, 2011, 01:40:11 PM
Quote from: alanjt link=topic=40164.msg454428#msg454428 It should - works on my machine...
[/quote

what do you use to make that animation?

my tabs are up top so i dont know if i could get it to work
Title: Re: how can i display dimscale with active dwg
Post by: alanjt on November 29, 2011, 01:44:45 PM
I use Camtasia for screen capturing and Drawing Tabs Manager (http://www.caelink.com/drawing_tabs.htm) for the obvious.
Title: Re: how can i display dimscale with active dwg
Post by: BlackBox on November 29, 2011, 01:52:51 PM
I use Camtasia for screen capturing and Drawing Tabs Manager (http://www.caelink.com/drawing_tabs.htm) for the obvious.

Interesting, I've never used Drawing Tabs before, so I'm not sure where they differ, but I use AutoCAD's free bonus tool MDITabs (http://autodesk.blogs.com/between_the_lines/2009/04/autocad-free-bonus-tool-drawing-tabs-mditabs.html) and am quite happy with it.

** Edit to add - The AutoCAD 2010 .ARX file supports 2010 Database, meaning releases 2010-2012. Note there's a different file for 32-Bit, and 64-Bit environments.
Title: Re: how can i display dimscale with active dwg
Post by: alanjt on November 29, 2011, 02:32:34 PM
I use Camtasia for screen capturing and Drawing Tabs Manager (http://www.caelink.com/drawing_tabs.htm) for the obvious.

Interesting, I've never used Drawing Tabs before, so I'm not sure where they differ, but I use AutoCAD's free bonus tool MDITabs (http://autodesk.blogs.com/between_the_lines/2009/04/autocad-free-bonus-tool-drawing-tabs-mditabs.html) and am quite happy with it.
I've used it for years. I tried the AutoCAD one when it was released but went back to Drawing Tabs.