Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Variant type object arrays
#1
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
Reply


Messages In This Thread
Variant type object arrays - by anbra - Jul-28-2018, 05:37 PM
RE: Variant type object arrays - by buran - Jul-28-2018, 06:49 PM
RE: Variant type object arrays - by anbra - Jul-28-2018, 07:25 PM
RE: Variant type object arrays - by anbra - Jul-29-2018, 09:25 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  declaring object parameters with type JonWayn 2 900 Dec-13-2022, 07:46 PM
Last Post: JonWayn
Star Type Error: 'in' object is not callable nman52 3 3,392 May-01-2021, 11:03 PM
Last Post: nman52
  TypeError: 'type' object is not subscriptable Stef 1 4,521 Aug-28-2020, 03:01 PM
Last Post: Gribouillis
  Type coercion with Numpy arrays Mark17 2 2,527 Jul-24-2020, 02:04 AM
Last Post: scidam
  isinstance() always return true for object type check Yoki91 2 2,556 Jul-22-2020, 06:52 PM
Last Post: Yoki91
  AttributeError: type object 'FunctionNode' has no attribute '_TestValidateFuncLabel__ binhduonggttn 0 2,246 Feb-19-2020, 11:29 AM
Last Post: binhduonggttn
  Type hinting - return type based on parameter micseydel 2 2,484 Jan-14-2020, 01:20 AM
Last Post: micseydel
  Object of type set is not JSON serializable enigma619 5 12,247 Dec-19-2019, 03:30 PM
Last Post: enigma619
  type of object as a string Skaperen 1 2,288 Dec-02-2019, 08:01 AM
Last Post: midarq
  Object of type Scoreboard is not JSON serializable lsepolis123 9 9,446 Aug-13-2019, 11:22 AM
Last Post: lsepolis123

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020