COM question: How can I assign a COM object as a property of another COM object using COMate Plus?

Everything else that doesn't fall into one of the other PB categories.
eNano
User
User
Posts: 13
Joined: Wed Jun 05, 2024 4:48 pm

COM question: How can I assign a COM object as a property of another COM object using COMate Plus?

Post by eNano »

Hi,
I'm trying to generate a tool by connecting Autocad to my code using COMate
So far I can do some basic stuffs like creating standard things and executing some commands

Now I need to change the color of an object (for example a circle), and the color property seems to be another kind of object, when I get the color object with GetObjectProperty I believe I'm getting a copy of that color object and not the real one connected to the original circle

I believe that because when I change a property of the color nothing happens with the circle, but when I get the information back from the color object the values are updated.

How can I re-assign the color to the circle object?
Thanks a lot for any answer!

Code: Select all


;THIS IS JUST A FRAGMENT OF CODE TO EXPOSE THE PROBLEM, IT WILL NOT RUN

Define variantCoord.VARIANT

*safeArrayCoord.SAFEARRAY = saCreateSafeArray(#VT_R8, 0, 3)
V_ARRAY_DOUBLE( variantCoord ) = *safeArrayCoord

SA_DOUBLE(*safeArrayCoord, 0) = xVal.d
SA_DOUBLE(*safeArrayCoord, 1) = yVal.d
SA_DOUBLE(*safeArrayCoord, 2) = zVal.d

; Create a circle based on this command from Autocad API help
; https://help.autodesk.com/view/OARX/2025/ENU/?guid=GUID-837C702F-91A7-445B-8713-3099B94664BE

*result.COMateObject = acad\activeDoc\currentSpace\COM\GetObjectProperty( "AddCircle(" + Str(variantCoord) + " AS VARIANT ,"+ StrD(radius)+ " As DOUBLE )")


; Get trueColor property from circle
; properties are listed here 
; https://help.autodesk.com/view/OARX/2025/ENU/?guid=GUID-18ADF171-166F-4FF0-8ED6-5F83153A5649


; This property is an AcCmColor Object

*theColor.COMateObject = *result\GetObjectProperty("TrueColor")

; I think I'm getting a COPY of the object and not the original object linked to the circle, but I don't know how to verify that


; I try to change the color value based on the methods and properties listed here:
; https://help.autodesk.com/view/OARX/2025/ENU/?guid=GUID-D24C6BB5-5F87-42E7-907F-F27226B330E3

*theColor\Invoke("SetRGB(" + Str(Red.i) + " As LONG," + Str(Green.i) + " As LONG,"+ Str(Blue.i) + " As LONG )" )

; The result is Ok, but it only changes in this object and not in the circle

; QUESTION:
; HOW CAN I RE-ASSIGN AN OBJECT TO ANOTHER OBJECT AS A PROPERTY??