.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

passing late bound variant array to group

0 REPLIES 0
Reply
Message 1 of 1
Anonymous
415 Views, 0 Replies

passing late bound variant array to group

I have some code that needs to late bind to AutoCAD ActiveX from VB Net (so that it works over many AutoCAD versions)

 

Most of the code works OK, but I am having difficulty adding entities to a group
I believe the problem is in the marshaling of the variant array.

Any suggestions on how to get this working?

 

'works correctly when using  early binding

Dim mygroup as AcadGroup
Dim mylist() as AcadEntity

mygroup = GroupColl.Add("Test 1")

redim mylist(0)
mylist(0) =   ActiveDocument.ModelSpace.AddLine(New Double() {0, 0, 0}, New Double() {1, 1, 1})

mygroup.AppendItems(mylist)

 


'fails using late binding, with error at AppendItems of "Invalid object array"

Dim mygroup as Object
Dim mylist() as Object         ' or Dim mylist as Object

mygroup = GroupColl.Add("Test 1")

redim mylist(0)
mylist(0) =   ActiveDocument.ModelSpace.AddLine(New Double() {0, 0, 0}, New Double() {1, 1, 0})

mygroup.AppendItems(mylist)


'have also tried  (following suggestions from MLeslie00 on this forum)

 

mygroup.AppendItems(MarshalVariantArray (mylist))

 

Public Function MarshalVariantStringArray(ByVal ObjIn AsObject) _
               As <Runtime.InteropServices.MarshalAsAttribute( _
                                   Runtime.InteropServices.UnmanagedType.SafeArray, _
                                   SafeArraySubType:=Runtime.InteropServices.VarEnum.VT_VARIANT)> Object

       ReturnObjIn
End Function

0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost