×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Change part colour using SW API

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.

RE: Change part colour using SW API

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.

On justice and on friendship, there is no price, but there are established credit limits.

RE: Change part colour using SW API

BTW, part color is controlled with PartDoc::MaterialProperty

RE: Change part colour using SW API

(OP)
Great!

PartDoc::MaterialProperty

I'll try it immediately.
Thanks a lot.

RE: Change part colour using SW API

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

On justice and on friendship, there is no price, but there are established credit limits.

RE: Change part colour using SW API

(OP)
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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources