Using VBA to change an object&
I have found several guides for this, but they dont workwhat am i doing wrong?
Sub test() Dim pt(2) As Double Dim objText As AcadText Dim aCol As AcadAcCmColor ' defines insertion point pt(0) = 0 pt(1) = 0 pt(2) = 0 ' creates the text object Set objText = ThisDrawing.ModelSpace.AddText("test", pt, 10) ' puts it on the right layer objText.Layer = "0" ' makes it the right color aCol = New AcadAcCmColor aCol.ColorMethod = acColorMethodByRGB aCol.ColorIndex = 4 objText.TrueColor = aCol End Sub
when it reaches this line
aCol = New AcadAcCmColor
an exception is thrown saying
%1 is not a valid Win32 application
is it because i'm running the 64 bit version of autocad?
if anyone knows of an easier way to change the color of an object please advise Try this
' make it the right color objText.Color = acCyanor this
' make it the right color objText.Color = 4Both should work.
what version of autocad are you using?
the AcadText object does not have a color attribute
i am using 2012
I'm using all versions from 2007 to 2014. All versions up to and including 2013 use VB6 whereas 2014 uses VB7. Just because the autocomplete function does not show a 'Color' property does not meanit does not have one, some properties for some methods are missing. Color for the text object is one. Just type in Color as shown in my pevious post andit will work. Your code with my altertin works forme in AutoCAD 2012.
页:
[1]