Author Topic: setvariable fails in 2018, works in previous versions?  (Read 1890 times)

0 Members and 1 Guest are viewing this topic.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
setvariable fails in 2018, works in previous versions?
« on: September 20, 2017, 12:33:39 PM »
Riddle me this.... at the command line in 2018 this works.

Command: DYNMODE

Enter new value for DYNMODE <-3>: 3

Command: SETVAR
Enter variable name or [?] <DYNMODE>:

Enter new value for DYNMODE <3>: -3

Command: (setq *doc* (vla-get-activedocument (vlax-get-acad-object)))
#<VLA-OBJECT IAcadDocument 00000000293ddd08>

Command: (vla-setvariable *doc* "dynmode" 3)  ;;<<<<<works in earlier versions
; error: Automation Error. Error setting system variable;;; yet 2018 throws this

ronjonp

  • Needs a day job
  • Posts: 7529
Re: setvariable fails in 2018, works in previous versions?
« Reply #1 on: September 20, 2017, 12:47:58 PM »
Same behavior here .. although (SETVAR 'DYNMODE 3) works fine.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: setvariable fails in 2018, works in previous versions?
« Reply #2 on: September 20, 2017, 01:03:00 PM »
Thanks, ronjonp!

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: setvariable fails in 2018, works in previous versions?
« Reply #3 on: September 20, 2017, 01:11:54 PM »
Does it work if you supply a variant?, e.g.:
Code - Auto/Visual Lisp: [Select]
  1. (vla-setvariable *doc* "dynmode" (vlax-make-variant 3))

ronjonp

  • Needs a day job
  • Posts: 7529
Re: setvariable fails in 2018, works in previous versions?
« Reply #4 on: September 20, 2017, 02:12:40 PM »
Does it work if you supply a variant?, e.g.:
Code - Auto/Visual Lisp: [Select]
  1. (vla-setvariable *doc* "dynmode" (vlax-make-variant 3))
Command: (vla-setvariable *doc* "dynmode" (vlax-make-variant 3))
; error: Automation Error. Error setting system variable

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ChrisCarlson

  • Guest
Re: setvariable fails in 2018, works in previous versions?
« Reply #5 on: September 20, 2017, 03:01:14 PM »
Interesting, modifying it to vla-GetVariable works as expected.

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: setvariable fails in 2018, works in previous versions?
« Reply #6 on: September 21, 2017, 12:40:30 PM »
Don't have it installed here, so another diagnostic stab in the dark - what does the "available" function say (I think it's vlax-property-available-p...) about read-write status?
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

BIGAL

  • Swamp Rat
  • Posts: 1414
  • 40 + years of using Autocad
Re: setvariable fails in 2018, works in previous versions?
« Reply #7 on: September 22, 2017, 04:39:20 AM »
Just a dumb suggestion is it 3 or "3" some bright spark may have changed something.

Did not work on civ3d 2018 ???
« Last Edit: September 22, 2017, 04:47:25 AM by BIGAL »
A man who never made a mistake never made anything