Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change part colour using SW API

Status
Not open for further replies.

Hacaro

Industrial
Aug 14, 2002
10
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.
 
Replies continue below

Recommended for you

It is possible to change the part color with API, however, this does not override the face color if the face color or feature color if there iss a specific color set at that level.

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.

[bat]On justice and on friendship, there is no price, but there are established credit limits.[bat]
 
BTW, part color is controlled with PartDoc::MaterialProperty
 
Great!

PartDoc::MaterialProperty

I'll try it immediately.
Thanks a lot.
 
D'oh! It's "PartDoc::MaterialropertyValues". I didn't get it all when I cut-and-pasted before. Sorry.

[bat]On justice and on friendship, there is no price, but there are established credit limits.[bat]
 
Yep, this is the way to go! It works fine.
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor