vla-put-ColorMethod error

vla-put-ColorMethod error

joselggalan
Advocate Advocate
2,933 Views
9 Replies
Message 1 of 10

vla-put-ColorMethod error

joselggalan
Advocate
Advocate

I have encountered an error in vla-put-ColorMethod  in Autocad 2021 
Does somebody know anything about this?

 

(setq oCol (vla-getinterfaceobject
		       (vlax-get-acad-object)
		       (strcat "autocad.accmcolor."
			       (substr (getvar 'acadver) 1 2))))
(vla-put-ColorMethod oCol acColorMethodByRGB)
error: Automation error. The description has not been provided.

regards.

0 Likes
Accepted solutions (2)
2,934 Views
9 Replies
Replies (9)
Message 2 of 10

silambua36
Contributor
Contributor

Don't know much about ActiveX methods. But, I found this on autocad help.

 

"vla-put- functions correspond to every property, enabling you to update the value of that property (for example, vla-put-Color updates an object's Color property)."

 

may be it is just vla-put-color?

0 Likes
Message 3 of 10

ronjonp
Advisor
Advisor

@joselggalan wrote:

I have encountered an error in vla-put-ColorMethod  in Autocad 2021 
Does somebody know anything about this?

 

 

(setq oCol (vla-getinterfaceobject
		       (vlax-get-acad-object)
		       (strcat "autocad.accmcolor."
			       (substr (getvar 'acadver) 1 2))))
(vla-put-ColorMethod oCol acColorMethodByRGB)
error: Automation error. The description has not been provided.

 

regards.


Your example does not error for me ( AutoCAD 2021 ).

0 Likes
Message 4 of 10

Lee_Mac
Advisor
Advisor
Accepted solution

Does the following perform successfully without error? That is, operating on an AcCmColor object returned by the ActiveX TrueColor property of an object:

 

(defun c:test ( / c e o )
    (if (setq e (car (entsel)))
        (progn
            (setq o (vlax-ename->vla-object e)
                  c (vla-get-truecolor o)
            )
            (vla-put-colormethod c accolormethodbyrgb)
            (vla-setrgb c 037 131 218)
            (vla-put-truecolor o c)
        )
    )
    (princ)
)

 

Message 5 of 10

flannigan
Explorer
Explorer
Accepted solution

I ran into the same issue.

There are changes to AcCmColor for ObjectARX in 2021 - I remember coming across some documentation but can't find it now. 

 

In any case, I manage this issue with a check for 2021 as follows:

 

 

(if (< (atof (substr (getvar "ACADVER") 1 4)) 24) 
   (vla-put-colormethod oCol acColorMethodByRGB)
)
;; input RGB value
(setq rgb '(122 189 156))
;; 2021 accepts values without setting colormethod beforehand
(vla-SetRGB oCol (car rgb) (cadr rgb) (caddr rgb))
;; apply color to object
(vla-put-truecolor vla-obj oCol)

 

 

Which avoids a crash and works for all versions. 

I do the same with index colours and colorbook colours (vla-put-colorindex and  vla-SetColorBookColor)

0 Likes
Message 6 of 10

joselggalan
Advocate
Advocate

Thanks Lee,
This solves some problem for me.
I actually use it in many cases in my code.
But in some cases, like this table creation one, I need to use the same variable to assign colors to the different elements.
Maybe I can change some code to modify all this, but I find it strange and uncomfortable that it does not work using the vla-getinterfaceobject method that I have used for years.

 

joselggalan_0-1617540065792.png

 

 

 

0 Likes
Message 7 of 10

joselggalan
Advocate
Advocate
0 Likes
Message 8 of 10

joselggalan
Advocate
Advocate

Thanks flannigan,
this works but:
What happens when you want to use a different method on several entities or objects using the same oCol object obtained with vla-getinterfaceobject.?
View image:

 

joselggalan_0-1617542616449.png

 

I have to test it thoroughly.

0 Likes
Message 9 of 10

JamesMaeding
Advisor
Advisor

I just ran into this.

This code works on my 2021 but fails on a friend of mine's:

(DEFUN C:TESTCOLOR4 ( / color-list color-object object)
	(SETQ object (vlax-ename->vla-object (CAR (ENTSEL))))
	(SETQ color-list (cons acColorMethodByaci 4))
	(setq color-object (vla-GetInterfaceObject (vlax-get-acad-object) "AutoCAD.AcCmColor.24"))
	(vla-put-ColorMethod color-object (car color-list))
	(vla-put-ColorIndex color-object (cdr color-list))
	(vla-put-TrueColor object color-object)
)

 I tried commenting out the vla-put-colormethod and it worked on mine, but don't know yet if it helped my friend.

This is no good though. Works on one and not on the other, same acad version and updates???


internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties

0 Likes
Message 10 of 10

markruys2
Advocate
Advocate

seems they have fixed this bug in AutoCAD 2022

0 Likes