Help with syntax: Object.GetVariables(Var1, Var2) Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
anbraLT
Posts: 6
Joined: 25 Sep 2017, 01:14

Help with syntax: Object.GetVariables(Var1, Var2)

25 Sep 2017, 02:10

Basicly I need to get Object information by sending 1 variable/or no variable to function in AutoCAD though COM.
Was searching forums for hours(around 5, yes im desperate :headwall: ), and im stuck on syntax, dunno if this is even possible.
Short Function description Im trying to use:
object.GetXData AppName, XDataType, XDataValue
Where, GetXData - my fuction call/method I guess...
AppName - String input I need to send. Can send no input to Get all data. Then I recive array of all XDataType, XDataValue
XDataType, XDataValue - variables I need recive/see.

AutoCAD descrition of function if needed:
http://help.autodesk.com/view/ACD/2015/ENU/?guid=GUID-330FCA31-A2A9-47F0-972D-6915B6B98426

How my syntax should look, so I could "see" XDataType, XDataValue ?

Tried:
variable := object.GetXData("AppNameRandomString", XDataType, XDataValue)
MsgBox % XDataType XDataType[1] XDataType[1,1] XDataType[1][1] ; nothing

How does AHK knows, what variable in brackets () we send and which one we recive/read ?
AutoCAD doesn't give error if im calling with such syntax, though removing one of items in brackets starts giving error.

If id need to recive 1 variable.
Var := Object.Function
or
Object.Function(var)
works
So in theory, to recive 2 variables.
Object.Function(var1, var2) should work. Though I cant read values ( how do I know If I even get them ? )
Also I cannot use simpler function, where I do not need to "send" any parameters:
object.GetBoundingBox MinPoint, MaxPoint
Written in AHK should look like:
object.GetBoundingBox(MinPoint, MaxPoint)
MsgBox % MinPoint MinPoint[0] MinPoint[0, 1] MinPoint[0][1] ; doesn't give me anything.
MinPoint, MaxPoint - should be arrays.

As writing this post I got idea, for syntax, which work on some other cases.
If XDataType is array. need to write something like this :
variable := object.GetXData("AppNameRandomString", XDataType, XDataValue)
For Object/item in XDataType
MsgBox % XDataType[1]

Ok, this, didnt worked...

Please. Any help appreciated :)

Best Regards,
Anbra
anbraLT
Posts: 6
Joined: 25 Sep 2017, 01:14

Re: Help with syntax: Object.GetVariables(Var1, Var2)

25 Sep 2017, 07:52

Basicly BUMP

That should be easy for ppl with COM knowledge, how to read 2 parameters of object function ?...
object.GetMeVariable(SomethingIWantToSee1,SomethingIWantToSee2) ; how the syntax should look to read 2 values by calling once to program, or twice, as long as I get booth variables?...
MsgBox % SomethingIWantToSee1 ; .... ???
anbraLT
Posts: 6
Joined: 25 Sep 2017, 01:14

Re: Help with syntax: Object.GetVariables(Var1, Var2)

25 Sep 2017, 23:04

BUMP :headwall: BUMP :headwall: BUMP :headwall:
At least, anyone can confirm that syntax is correct here ?
Object.GetVariables(Var1, Var2)
tmplinshi
Posts: 1092
Joined: 01 Oct 2013, 14:57

Re: Help with syntax: Object.GetVariables(Var1, Var2)

25 Sep 2017, 23:29

variable := object.GetXData("AppNameRandomString", XDataType, XDataValue)

The syntax seems correct. However I wonder if you just using the object from nowhere. The object should created by ComObjCreate or ComObjActive.
anbraLT
Posts: 6
Joined: 25 Sep 2017, 01:14

Re: Help with syntax: Object.GetVariables(Var1, Var2)

26 Sep 2017, 01:01

Yes, I create AutoCAD object, ComObjActive("AutoCAD.Application")
And everything is fine, I made "a lot" scripts though COM for autocad, just got stuck on the syntax.

object.Coordinate(ArrayOfXYZ) - I can see coordinates in array

But, why this doesn't give any answers.
object.GetBoundingBox(MinPoint, MaxPoint)
MsgBox % MinPoint MinPoint[0] MinPoint[0, 1] MinPoint[0][1] ; doesn't give me anything.
MinPoint should give same 3 coordinates XYZ as object.Coordinate(ArrayOfXYZ), the difference is object.GetBoundingBox calls back two coordinates, start and end of box.
Strange. So in theory, you confirm syntax is okay. thus I need to find a way how to "decode" the variable I get.
tmplinshi
Posts: 1092
Joined: 01 Oct 2013, 14:57

Re: Help with syntax: Object.GetVariables(Var1, Var2)

26 Sep 2017, 01:42

Try:

Code: [Select all] [Download] GeSHi © Codebox Plus

MinPoint := ComObjArray(VT_VARIANT:=12, 3)
MinPoint := ComObjArray(VT_VARIANT:=12, 3)

object.GetBoundingBox(ComObjValue(MinPoint), ComObjValue(MaxPoint))
MsgBox, % MinPoint[0] "," MinPoint[1] "," MinPoint[2]
anbraLT
Posts: 6
Joined: 25 Sep 2017, 01:14

Re: Help with syntax: Object.GetVariables(Var1, Var2)

26 Sep 2017, 02:13

Now we talking :)
Thanks man !
Will try this as soon as I can.

can you further explain what "VT_VARIANT:=12" stands for ? 3 is for the array "size", 3 coordinates. but 12 ?

Also, why is it so if I use object.Coordinates(VariablesArray), I do not need to create extra ComObjArray to read values in VariablesArray, while if I use call for "multiple" arrays I need this ? Or this might be, that AutoCAD gives those arrays as COM objects, instead simple arrays, maybe that's the case I cant see values.

Anyways, ill update this post if I succeed/fail using Your method.
Thanks once again
User avatar
Blackholyman
Posts: 1239
Joined: 29 Sep 2013, 22:57
Facebook: socialjsz
Google: +Jszapp
Location: Denmark
Contact:

Re: Help with syntax: Object.GetVariables(Var1, Var2)

26 Sep 2017, 02:37

ComObjArray() needs to know the base type of the array for that you need to use one from the subset of the variant type codes in this case VT_VARIANT aka 12

you can also try other combinations for the type SafeArray := ComObjArray(Type := (VT_VARIANT:=0xC) | (VT_ARRAY := 0x2000), 3)
anbraLT
Posts: 6
Joined: 25 Sep 2017, 01:14

Re: Help with syntax: Object.GetVariables(Var1, Var2)

26 Sep 2017, 03:13

MinPoint := ComObjArray(Type := (VT_VARIANT:=0xC) | (VT_ARRAY := 0x2000), 3)
MaxPoint := ComObjArray(VT_VARIANT:=12, 3)
object.GetBoundingBox(ComObjValue(MinPoint), ComObjValue(MaxPoint))
MsgBox, % MinPoint "," MinPoint[0] "," MinPoint[1] "," MinPoint[2] "," MaxPoint "," MaxPoint[2]

This gave me nothing. Any more ideas ?... :/

AutoCAD gives no errors, thus meaning, that we call to object.GetBoundingBox correctly with 2 "variables" though... what are in those variables, or even if we can read them... dunno...
As mentioned before, if its 1 variable array, I don't need to make safearray or new COM objects.
But im willing to try any given ideas, as this drives me crazy, not figuring out whats wrong with this, as in theory everything seems legit.
tmplinshi
Posts: 1092
Joined: 01 Oct 2013, 14:57

Re: Help with syntax: Object.GetVariables(Var1, Var2)  Topic is solved

05 Oct 2017, 11:54

I got hope by seeing this answer, install AutoCAD again and finally figured out: :)

Code: [Select all] [Expand] [Download] (AutoCADExample.ahk)GeSHi © Codebox Plus


Return to “Ask For Help”

Who is online

Users browsing this forum: Diego and 49 guests