TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started 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
(setq App (vlax-Get-Acad-Object)
Doc (vla-Get-ActiveDocument App)
)
(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"))
-
Your setting your modemacro with a string rather than an equation.
(setvar 'MODEMACRO (blah blah))
Here's mine:
("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*) "
)
-
Your setting your modemacro with a string rather than an equation.
(setvar 'MODEMACRO (blah blah))
Here's mine:
("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
-
Your setting your modemacro with a string rather than an equation.
(setvar 'MODEMACRO (blah blah))
Here's mine:
("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.
(setvar "modemacro" blah blah)
-
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.
-
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)
-
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 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...
-
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.
-
I agree, it works, but it might be some issues with some extra returns and such, here is exactly how I have it:
(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*) ")
-
I agree, it works, but it might be some issues with some extra returns and such, here is exactly how I have it:
(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.
-
what do you use to make that animation?
my tabs are up top so i dont know if i could get it to work
-
I use Camtasia for screen capturing and Drawing Tabs Manager (http://www.caelink.com/drawing_tabs.htm) for the obvious.
-
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.
-
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.