Change Select Set Face Colour Simultaneously

Change Select Set Face Colour Simultaneously

matt_jlt
Collaborator Collaborator
678 Views
3 Replies
Message 1 of 4

Change Select Set Face Colour Simultaneously

matt_jlt
Collaborator
Collaborator

Is there any way to change the colour of all faces in a select set simultaneously?

 

The method I am referring to is when you select faces in a part document, rickt click and select properties from the context menu, a dialog box pops up called "Face Properties" which prompts you to select a colour and click OK. when this is done all of the faces are changed at once.

 

How do I replicate this via the API?

 

Currently I have it iterate through each face in a part document and apply the colour override one by one which can take a while when there are about 1000 faces. You can see each face changing as you go.

 

Any help is appreciated.

 

Regards, Matt.

0 Likes
679 Views
3 Replies
Replies (3)
Message 2 of 4

philippe.leefsma
Alumni
Alumni

Hi Matt,

 

Well, there isn't a specific approach to change faces color but in general if you wrap your API calls inside a global Transaction it should help the performances a bit:

 

Dim tx As Transaction
Set tx = ThisApplication.TransactionManager.StartGlobalTransaction(doc, "test")
    
    'Do yout stuff...
    
'Don't forget to end teh transaction
tx.End

 You can also use the ChangeProcessor feature to handle the task. See API help files for more details about ChangeProcessor.

 

I hope it helps,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 4

adam.nagy
Autodesk Support
Autodesk Support

Hi,

 

You can set the color at 3 levels: part level, feature level, face level.

If you want to change the color of each face in the part then you could just change the color of the part. That would be a single operation without having to go through all the faces.

Would that suit your needs?

 

http://modthemachine.typepad.com/my_weblog/2009/02/controlling-part-colors.html

 

If you really need to modify the color of each face separately, then you could have a look at this AU class that talks about improving performance: http://au.autodesk.com/?nd=event_class&session_id=10566&jid=611044

 

Cheers,



Adam Nagy
Autodesk Platform Services
0 Likes
Message 4 of 4

matt_jlt
Collaborator
Collaborator

Thanks Philippe and Adam, i forgot about the transaction manager and i'll hav a look into using more processors.

 

My main purpose for this is I quite regularly get 3rd party models that i need to remove all of the imported colour overrides on each face. Once that is done, I apply a part level colour change.

 

My code currently disables the user interface / updating of inventor, iterates through each face, feature etc in a part and sets the colour back to default. This can take quite a while on my large parts.

 

I was thinking i could just have all of the faces add to a select set then manually right click and change colour that way or use Send Keys to achieve the same result but that is a poor solution. I might have that as an optional command if i want to speed things up a bit.

 

Regards, Matt.

0 Likes