SetVariable

SetVariable

Anonymous
Not applicable
1,284 Views
9 Replies
Message 1 of 10

SetVariable

Anonymous
Not applicable
I have nothing better to do than play stupid games with AutoCad VBA!!!

Please, would someone be so kind as to explain why I can't set FILEDIA via
the setvariable method in VBA?

I click on the file open button with filedia set to 0, I get prompted on the
command-line. When I run this routine with the setvariable line
uncommented, I still get prompted on the command-line. When I use the
sendcommand line, it works.

Ideas?


Sub Set_ODM_Defaults()
' set default values for common variables
'
' all routines (lisp, vba, etc) should
' save current settings before changing values
' then reset values after use - but they don't
' this routine should reset most common settings

ThisDrawing.SetVariable "acadlspasdoc", 1
ThisDrawing.SetVariable "attdia", 1
ThisDrawing.SetVariable "blipmode", 0
ThisDrawing.SetVariable "cmddia", 1
ThisDrawing.SetVariable "dimunit", 2
ThisDrawing.SetVariable "dimtxt", 0.18
ThisDrawing.SetVariable "textsize", 0.18
ThisDrawing.SetVariable "dimasz", 0.18
ThisDrawing.SetVariable "dimadec", 3
ThisDrawing.SetVariable "dimupt", 1
' ThisDrawing.SetVariable "filedia", 1
ThisDrawing.SendCommand "filedia 1 "
ThisDrawing.SetVariable "mirrtext", 0
ThisDrawing.SetVariable "osmode", 1025
ThisDrawing.SetVariable "sdi", 0
ThisDrawing.SetVariable "userr1", 1
SetTextStyle
End Sub
0 Likes
1,285 Views
9 Replies
Replies (9)
Message 2 of 10

Anonymous
Not applicable
Kieth, I could not reproduce what you explained. I did not run your routine,
but everything looks fine there. After you run the routine are saying
filedia is still set to 0, or is it set to 1 and you are getting command
line prompts? If the latter is the case then I don't really know what to
say, I would guess that's not the case though. Have you gone through all the
usual debugging to ensure you code is being executed as expected?

Regards,
Jacob Dinardi

"Keith" wrote in message
news:3BC8AB9830C4AE6060EAFDA2CEB2F9B1@in.WebX.maYIadrTaRb...
> I have nothing better to do than play stupid games with AutoCad VBA!!!
>
> Please, would someone be so kind as to explain why I can't set FILEDIA via
> the setvariable method in VBA?
>
> I click on the file open button with filedia set to 0, I get prompted on
the
> command-line. When I run this routine with the setvariable line
> uncommented, I still get prompted on the command-line. When I use the
> sendcommand line, it works.
>
> Ideas?
>
>
> Sub Set_ODM_Defaults()
> ' set default values for common variables
> '
> ' all routines (lisp, vba, etc) should
> ' save current settings before changing values
> ' then reset values after use - but they don't
> ' this routine should reset most common settings
>
> ThisDrawing.SetVariable "acadlspasdoc", 1
> ThisDrawing.SetVariable "attdia", 1
> ThisDrawing.SetVariable "blipmode", 0
> ThisDrawing.SetVariable "cmddia", 1
> ThisDrawing.SetVariable "dimunit", 2
> ThisDrawing.SetVariable "dimtxt", 0.18
> ThisDrawing.SetVariable "textsize", 0.18
> ThisDrawing.SetVariable "dimasz", 0.18
> ThisDrawing.SetVariable "dimadec", 3
> ThisDrawing.SetVariable "dimupt", 1
> ' ThisDrawing.SetVariable "filedia", 1
> ThisDrawing.SendCommand "filedia 1 "
> ThisDrawing.SetVariable "mirrtext", 0
> ThisDrawing.SetVariable "osmode", 1025
> ThisDrawing.SetVariable "sdi", 0
> ThisDrawing.SetVariable "userr1", 1
> SetTextStyle
> End Sub
>
>
>
0 Likes
Message 3 of 10

Anonymous
Not applicable
I tried to reproduce it as well, and I couldn't, your code worked
fine! Just to try and help check out a couple things:

How do you activate the open command?

if from Pulldown File->Open:
make sure your menu doesn't have a macro to set filedia to 0

if CTRL + O:
make sure your accelerators in the menu are not setting filedia to 0

if ToolBar Open:
make sure the code behind the button is not setting filedia to 0

Otherwise I have no idea. sowwwwy.

joseguia
janitor


"Jacob Dinardi" wrote in
message news:15B7A9D5CE6EACA681376F396A957D36@in.WebX.maYIadrTaRb...
> Kieth, I could not reproduce what you explained. I did not run your
routine,
> but everything looks fine there. After you run the routine are saying
> filedia is still set to 0, or is it set to 1 and you are getting command
> line prompts? If the latter is the case then I don't really know what to
> say, I would guess that's not the case though. Have you gone through all
the
> usual debugging to ensure you code is being executed as expected?
>
> Regards,
> Jacob Dinardi
>
> "Keith" wrote in message
> news:3BC8AB9830C4AE6060EAFDA2CEB2F9B1@in.WebX.maYIadrTaRb...
> > I have nothing better to do than play stupid games with AutoCad VBA!!!
> >
> > Please, would someone be so kind as to explain why I can't set FILEDIA
via
> > the setvariable method in VBA?
> >
> > I click on the file open button with filedia set to 0, I get prompted on
> the
> > command-line. When I run this routine with the setvariable line
> > uncommented, I still get prompted on the command-line. When I use the
> > sendcommand line, it works.
> >
> > Ideas?
> >
> >
> > Sub Set_ODM_Defaults()
> > ' set default values for common variables
> > '
> > ' all routines (lisp, vba, etc) should
> > ' save current settings before changing values
> > ' then reset values after use - but they don't
> > ' this routine should reset most common settings
> >
> > ThisDrawing.SetVariable "acadlspasdoc", 1
> > ThisDrawing.SetVariable "attdia", 1
> > ThisDrawing.SetVariable "blipmode", 0
> > ThisDrawing.SetVariable "cmddia", 1
> > ThisDrawing.SetVariable "dimunit", 2
> > ThisDrawing.SetVariable "dimtxt", 0.18
> > ThisDrawing.SetVariable "textsize", 0.18
> > ThisDrawing.SetVariable "dimasz", 0.18
> > ThisDrawing.SetVariable "dimadec", 3
> > ThisDrawing.SetVariable "dimupt", 1
> > ' ThisDrawing.SetVariable "filedia", 1
> > ThisDrawing.SendCommand "filedia 1 "
> > ThisDrawing.SetVariable "mirrtext", 0
> > ThisDrawing.SetVariable "osmode", 1025
> > ThisDrawing.SetVariable "sdi", 0
> > ThisDrawing.SetVariable "userr1", 1
> > SetTextStyle
> > End Sub
> >
> >
> >
>
>
0 Likes
Message 4 of 10

Ed__Jobe
Mentor
Mentor
Try typing the line in the Immediate window. If it doesn't work, you have some other problem going on. -Ed

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 5 of 10

Anonymous
Not applicable
I feel better knowing things look ok. 😉

From the Autocad interface, I type filedia at the command line to see the
current setting. It is 0. I click on the toolbar button for _open and get
a prompt on the command line. I hit ESC and type filedia. It is 0 so I
change it to 1. I click on the open button and get the dialog box. I
cancel that and change filedia back to 0. Click on button to ensure I am
getting the command line prompt. Run my VBA routine, which had a message
box before and after the setvariable command. The message box was "msgbox
thisdrawing.getvariable("filedia") and showed the 0 before the setvariable
line and showed a 1 after the setvariable line. When the sub finished, I
again checked the filedia at the command line and it was still 0.

I'll try re-booting and then try it again. Who knows.....rebooting has
fixed many a problem......

Thanks for your help. I'll double-check the code in the toolbar button -
just to be sure.

Keith


"Jose Guia" wrote in message
news:478EE77996E1D8387D67B76A3A5E2885@in.WebX.maYIadrTaRb...
> I tried to reproduce it as well, and I couldn't, your code worked
> fine! Just to try and help check out a couple things:
>
> How do you activate the open command?
>
> if from Pulldown File->Open:
> make sure your menu doesn't have a macro to set filedia to 0
>
> if CTRL + O:
> make sure your accelerators in the menu are not setting filedia to 0
>
> if ToolBar Open:
> make sure the code behind the button is not setting filedia to 0
>
> Otherwise I have no idea. sowwwwy.
>
> joseguia
> janitor
>
>
> "Jacob Dinardi" wrote in
> message news:15B7A9D5CE6EACA681376F396A957D36@in.WebX.maYIadrTaRb...
> > Kieth, I could not reproduce what you explained. I did not run your
> routine,
> > but everything looks fine there. After you run the routine are saying
> > filedia is still set to 0, or is it set to 1 and you are getting command
> > line prompts? If the latter is the case then I don't really know what to
> > say, I would guess that's not the case though. Have you gone through all
> the
> > usual debugging to ensure you code is being executed as expected?
> >
> > Regards,
> > Jacob Dinardi
> >
> > "Keith" wrote in message
> > news:3BC8AB9830C4AE6060EAFDA2CEB2F9B1@in.WebX.maYIadrTaRb...
> > > I have nothing better to do than play stupid games with AutoCad VBA!!!
> > >
> > > Please, would someone be so kind as to explain why I can't set FILEDIA
> via
> > > the setvariable method in VBA?
> > >
> > > I click on the file open button with filedia set to 0, I get prompted
on
> > the
> > > command-line. When I run this routine with the setvariable line
> > > uncommented, I still get prompted on the command-line. When I use
the
> > > sendcommand line, it works.
> > >
> > > Ideas?
> > >
> > >
> > > Sub Set_ODM_Defaults()
> > > ' set default values for common variables
> > > '
> > > ' all routines (lisp, vba, etc) should
> > > ' save current settings before changing values
> > > ' then reset values after use - but they don't
> > > ' this routine should reset most common settings
> > >
> > > ThisDrawing.SetVariable "acadlspasdoc", 1
> > > ThisDrawing.SetVariable "attdia", 1
> > > ThisDrawing.SetVariable "blipmode", 0
> > > ThisDrawing.SetVariable "cmddia", 1
> > > ThisDrawing.SetVariable "dimunit", 2
> > > ThisDrawing.SetVariable "dimtxt", 0.18
> > > ThisDrawing.SetVariable "textsize", 0.18
> > > ThisDrawing.SetVariable "dimasz", 0.18
> > > ThisDrawing.SetVariable "dimadec", 3
> > > ThisDrawing.SetVariable "dimupt", 1
> > > ' ThisDrawing.SetVariable "filedia", 1
> > > ThisDrawing.SendCommand "filedia 1 "
> > > ThisDrawing.SetVariable "mirrtext", 0
> > > ThisDrawing.SetVariable "osmode", 1025
> > > ThisDrawing.SetVariable "sdi", 0
> > > ThisDrawing.SetVariable "userr1", 1
> > > SetTextStyle
> > > End Sub
> > >
> > >
> > >
> >
> >
>
>
0 Likes
Message 6 of 10

Anonymous
Not applicable
Why are you doing a SendCommand instead of a SetVariable here? Have you
tried it with: ThisDrawing.SetVariable "filedia", 1


> > > > ThisDrawing.SendCommand "filedia 1 "


Jeff
--
Jeff Spannbauer
Civil Engineer III
Cannon Associates
www.cannonassoc.com
805-544-7407
0 Likes
Message 7 of 10

Anonymous
Not applicable
🙂

Hi, Jeff. Yes. That particular setvariable just alllllll of a sudddddden
quit working. Those surrounding it work fine. Just the filedia variable.
Goofy, huh?

Wellllllll, the reboot worked. Things are working normally now. Sorry to
have bothered everyone without doing the primary bug fix : reboot.



"Jeff Spannbauer" wrote in message
news:48F3B76F2F82F964D52238E90C4F3467@in.WebX.maYIadrTaRb...
>
> Why are you doing a SendCommand instead of a SetVariable here? Have you
> tried it with: ThisDrawing.SetVariable "filedia", 1
>
>
> > > > > ThisDrawing.SendCommand "filedia 1 "
>
>
> Jeff
> --
> Jeff Spannbauer
> Civil Engineer III
> Cannon Associates
> www.cannonassoc.com
> 805-544-7407
>
>
>
0 Likes
Message 8 of 10

Anonymous
Not applicable
Usually Mechanical Desktop knows when my computer needs to reboot and just
does it for me. I used to think of it as a "limitation" now I'm starting to
see the genius of Autodesk!

"Keith" wrote in message
news:443840CB8BCC91245AD801F54AB533F5@in.WebX.maYIadrTaRb...
> 🙂
>
> Hi, Jeff. Yes. That particular setvariable just alllllll of a sudddddden
> quit working. Those surrounding it work fine. Just the filedia variable.
> Goofy, huh?
>
> Wellllllll, the reboot worked. Things are working normally now. Sorry to
> have bothered everyone without doing the primary bug fix : reboot.
>
>
>
> "Jeff Spannbauer" wrote in message
> news:48F3B76F2F82F964D52238E90C4F3467@in.WebX.maYIadrTaRb...
> >
> > Why are you doing a SendCommand instead of a SetVariable here? Have you
> > tried it with: ThisDrawing.SetVariable "filedia", 1
> >
> >
> > > > > > ThisDrawing.SendCommand "filedia 1 "
> >
> >
> > Jeff
> > --
> > Jeff Spannbauer
> > Civil Engineer III
> > Cannon Associates
> > www.cannonassoc.com
> > 805-544-7407
> >
> >
> >
>
>
0 Likes
Message 9 of 10

Anonymous
Not applicable
ROTFLOL

With enough spontaneous reboots, no one will be able to complain about bugs,
right?!


"Jacob Dinardi" wrote in
message news:714B1DCEC105224CF11111968D2842BF@in.WebX.maYIadrTaRb...
> Usually Mechanical Desktop knows when my computer needs to reboot and just
> does it for me. I used to think of it as a "limitation" now I'm starting
to
> see the genius of Autodesk!
0 Likes
Message 10 of 10

Anonymous
Not applicable
Keeps it interesting anyway... lol.

"R. Robert Bell" wrote in message
news:EE14DB8B4AA4074AA1C45B84C279861F@in.WebX.maYIadrTaRb...
> ROTFLOL
>
> With enough spontaneous reboots, no one will be able to complain about
bugs,
> right?!
>
>
> "Jacob Dinardi" wrote in
> message news:714B1DCEC105224CF11111968D2842BF@in.WebX.maYIadrTaRb...
> > Usually Mechanical Desktop knows when my computer needs to reboot and
just
> > does it for me. I used to think of it as a "limitation" now I'm starting
> to
> > see the genius of Autodesk!
>
>
>
0 Likes