Good day everyone,
I've been making some scripts with Autohotkey before and decided to move forwards and learn python(i know there is ironpython for making .NET scritps for autocad, but for now, id like to learn "basics").
Just started, few days ago, and wanted to make COM object to connect to autocad.
I managed to do everyting and connect to COM object with the help of "pyautocad" library.
where i'm stuck is in making selection set filter parameters, as its is not documented in pyautocad(maybe?).
So, in Autohotkey script looks like this(syntax is simmilar, shouldnt be problem as example):
So, i make 2 objects/variables : FilterType, FilterData.
FilterType := VarArrayCreate(VT_I2 := 2, "0", "8") # i send 3 variables to my function VarArrayCreate(below), with variables VT_I2 := 2 is same as just sending "2", but we can see datatype more clearly, not just digit. so, 2 stands for "16-bit signed int" in autohotkey, for more read here - autohotkey Object types. , next variable is "0" - autocad dxfCode, baiscly 0 is for autocad object types, like: lines, circle, polyline, etc..., last variable "8" - same, as 0, just for Layers.
FilterData := VarArrayCreate(VT_VARIANT := 0xC, "line", "LayerName") # Basicly same as above, just the type of 0xC is VARIANT.
So with FilterType i call funtion below. and create array object of "16-bit signed int", and with FilterData "VARIANT" type array.
VarArrayCreate(Type=0xC, Values*) #VarArrayCreate - this is function name, in python case, class ???
{
arr := ComObjArray(Type, Values.MaxIndex()) #this basicly creates ComObject with datatype that have sent parameters.
for i, v in Values{
arr[i-1] := v # -1 is needed becouse in autohotkey array starts with 1, and in autocad it should start from 0
}
return arr
}
So in General i need two arrays, one of 16bit integers, and other with variant type.
Looks kinda simple function, yet i cant figure out how to create such object array with specific type of data.
Any help appreciated,
And please make short example with core only, and not 300 lines codes, im new, i wont figure out such things(unless they work and all i need to send my variables :) )
To provoke on answer, one should ask, is Python inferior in object based arrays than AutoHotkey ? :D
I've been making some scripts with Autohotkey before and decided to move forwards and learn python(i know there is ironpython for making .NET scritps for autocad, but for now, id like to learn "basics").
Just started, few days ago, and wanted to make COM object to connect to autocad.
I managed to do everyting and connect to COM object with the help of "pyautocad" library.
where i'm stuck is in making selection set filter parameters, as its is not documented in pyautocad(maybe?).
So, in Autohotkey script looks like this(syntax is simmilar, shouldnt be problem as example):
So, i make 2 objects/variables : FilterType, FilterData.
FilterType := VarArrayCreate(VT_I2 := 2, "0", "8") # i send 3 variables to my function VarArrayCreate(below), with variables VT_I2 := 2 is same as just sending "2", but we can see datatype more clearly, not just digit. so, 2 stands for "16-bit signed int" in autohotkey, for more read here - autohotkey Object types. , next variable is "0" - autocad dxfCode, baiscly 0 is for autocad object types, like: lines, circle, polyline, etc..., last variable "8" - same, as 0, just for Layers.
FilterData := VarArrayCreate(VT_VARIANT := 0xC, "line", "LayerName") # Basicly same as above, just the type of 0xC is VARIANT.
So with FilterType i call funtion below. and create array object of "16-bit signed int", and with FilterData "VARIANT" type array.
VarArrayCreate(Type=0xC, Values*) #VarArrayCreate - this is function name, in python case, class ???
{
arr := ComObjArray(Type, Values.MaxIndex()) #this basicly creates ComObject with datatype that have sent parameters.
for i, v in Values{
arr[i-1] := v # -1 is needed becouse in autohotkey array starts with 1, and in autocad it should start from 0
}
return arr
}
So in General i need two arrays, one of 16bit integers, and other with variant type.
Looks kinda simple function, yet i cant figure out how to create such object array with specific type of data.
Any help appreciated,
And please make short example with core only, and not 300 lines codes, im new, i wont figure out such things(unless they work and all i need to send my variables :) )
To provoke on answer, one should ask, is Python inferior in object based arrays than AutoHotkey ? :D