Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Changing 3d sketch color through API

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Carter.Mast
831 Views, 3 Replies

Changing 3d sketch color through API

Hello-

 

I am trying to change the color of a sketch point in a 3d sketch through the Inventor API based on the file state in Vault. Currently I have all parts working, with the exception of setting the point color. 

 

I would like to replicate the result obtainable through the UI by navigating to the point in question, rt. click on the 3d sketch->Properties-> then set the color.

 

The basics of my set color function are shown below in a VBA snippet:

 

 

 

Dim thePartDoc As PartDocument
Set thePartDoc = ThisApplication.ActiveDocument

Dim partComp As PartComponentDefinition
Set partComp = thePartDoc.ComponentDefinition

Dim threeDSketch As Sketch3D
Set threeDSketch = partComp.Sketches3D.Item(1)
Dim red As Inventor.Color
Set red = ThisApplication.TransientObjects.CreateColor(255, 0, 0)

threeDSketch.OverrideColor = red

 

 

 

However, this does not produce the desired result.

 

I also tried using the point object within the 3d sketch iteself (threeDSketch.SketchPoints3D.Item(1) ), but this does not appear to have a color setting. I then tried to capture the event throught the Event Watcher, but this did not produce a result that I was able to replicate, even using a selection set.  

 

Does anyone have any ideas or thoughts? I have attached a sample file.

 

Ultimately these points are being used in an assembly collection of points, so if the color can be changed at the assembly level that is a valid solution as well.

 

 

 

 

 

 

 

3 REPLIES 3
Message 2 of 4

Unfortunately I couldn't find a way to achieve the color change like in the UI... I asked the API Team and I will let you know if I get a positive feedback.

 

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 3 of 4

Thank you for your reply.

 

Fortunatly I was able to accomplish my goal using code similar to that shown above.

 

The trick? Make sure the color property for the sketch is set to "Default". This will allow changes through the UI.

 

My previous attempts had the skecth color set to "Yellow", thus negating/overriding the command from the API.

 

See image below.

 

Thanks for your help in looking into this.

 

Carter

Message 4 of 4

Yes setting the color at the sketch level with the API only works if the sketch and the contained entities have their color set to default in the UI.

 

We also have a request logged to expose sketch entity color to the APi but it hasn't been implemented yet.

 

Thanks for letting us know,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report