VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Changing Color of object using autocad Vba

1 REPLY 1
Reply
Message 1 of 2
ajoshi1967
6722 Views, 1 Reply

Changing Color of object using autocad Vba

Dear All

 

I used following code to change the colour of Line in AutoCAD 2013 32-bit.

 

Sub Ch4_ColorCircle()

    Dim color As New AcadAcCmColor
    Call color.SetRGB(80, 100, 244)
    Dim circleObj As AcadCircle
    Dim centerPoint(0 To 2) As Double
    Dim radius As Double
    centerPoint(0) = 0#: centerPoint(1) = 0#: centerPoint(2) = 0#
    radius = 5#
    Set circleObj = ThisDrawing.ModelSpace.AddCircle(centerPoint, radius)
    circleObj.TrueColor = color
    ZoomAll

End Sub

 

The program worked nicely.

 

but when I ran the program in AutoCAD 2013 64-bit I got following message for code (Call color.SetRGB(80, 100, 244))

 

Automation Error

 

%1 is not a valid Win32 application.

 

Can any help solve this problem. Is this problem related to 64-bit AutoCAD.

1 REPLY 1
Message 2 of 2

Hi,

 

if you change your first line with Dim .... to that:

    Dim color As AcadAcCmColor
    Set color = ThisDrawing.Application.GetInterfaceObject("AutoCAD.AcCmColor.19")

Does that work?

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)

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

Post to forums  

Autodesk Design & Make Report

”Boost