Change part colour using SW API
Change part colour using SW API
(OP)
I am trying to change the colour of a part document using VB.
Is it necessary to select every single face and set the desired colour or is it possible to change the colour of the part in one simple operation?
I think it is possible since it's posible in SW (select the first feature in the tree and push change colour button).
Any help would be appreciated.
Is it necessary to select every single face and set the desired colour or is it possible to change the colour of the part in one simple operation?
I think it is possible since it's posible in SW (select the first feature in the tree and push change colour button).
Any help would be appreciated.






RE: Change part colour using SW API
You may want to include a subroutine to reset the face colors of all the faces in a selected body. I believe there are examples for this in the API help. Look under "Face2:MaterialPropertyValues", "GetFirstFace" and "GetNextFace" in the API help index.
RE: Change part colour using SW API
RE: Change part colour using SW API
PartDoc::MaterialProperty
I'll try it immediately.
Thanks a lot.
RE: Change part colour using SW API
RE: Change part colour using SW API
Just took me a while to figure out how to pass the "safearray".
This is the way to do it:
1) define a variant and an array of doubles
2) assign the desired values to each member of the array
3) variant = array
4) pass the variant between brackets!
ex. MaterialropertyValues (variant)
Then everything works fine.
This only seems to work for VB and not for VBA.