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: 

Set SolidBody Property: Body Appearance to "As Part"

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
snappyjazz
464 Views, 3 Replies

Set SolidBody Property: Body Appearance to "As Part"

Hello,

I am converting an STP file to a ipt or iam. While I'm doing that I am making sure some options and settings are set the way we like it. Right now I'm getting stuck trying to set the Body Appearance property of the solid body. I would also like to check the box to Clear All Overrides. I have found other posts that showed how to set this as a color in the list. However I want to set it to As Part. Which isn't in the appearance library. Does anyone know how to set it? 

 

snappyjazz_0-1692821692523.png

 

snappyjazz_1-1692821713147.png

 

snappyjazz_2-1692821727677.png

 

 

 

 

Labels (3)
3 REPLIES 3
Message 2 of 4
A.Acheson
in reply to: snappyjazz

Hi @snappyjazz 

 

Removing the overide I think is all you need. Appearance should default back to document appearance. If it doesn't meesage back with any error messages etc. See API help here.

 

Syntax
SurfaceBody.ClearAppearanceOverrides()

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 3 of 4
WCrihfield
in reply to: snappyjazz

Hi @snappyjazz.  I am a little confused, because your code window seems to indicate that you are working with an assembly, and a variable named 'Occurance', which sounds similar to ComponentOccurrence (the API object for an assembly component), but your post title, and lower images indicate a SurfaceBody API object.  If it is truly a solid body within a part, then what Alan suggested above should work OK.  But if it is a component within an assembly, that is a different story.  The ComponentOccurrence API object has a few properties you might be able to use.

 

ComponentOccurrence.AppearanceSourceType, which is a Read/Write property with a value from the AppearanceSourceTypeEnum.

ComponentOccurrence.Appearance, which has an Asset type value.

But before trying to mess with either of those on individual components, you could first try using the method of the main AssemblyComponentDefinition.ClearAppearanceOverrides, which takes an optional input ObjectCollection containing some components.  Then the other route might be to do this through the active DVR (DesignViewRepresentation), which has the DesignViewRepresentation.RemoveAppearanceOverrides method, but that will clear all appearance overrides under the control of that DVR, with no optional input objects.

Edit:  There is also the PartComponentDefinition.ClearAppearanceOverrides method, which also takes an optional input ObjectCollection, that can contain several types of things that are common in parts.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 4 of 4
snappyjazz
in reply to: WCrihfield

@A.Acheson Ah, thank you. I missed that when I was looking through the options of the "SurfaceBody" object.

 

@A.Acheson You're correct. In the code posted I am working with an assembly. Some of the STP files we get are assemblies. One of the things I wanted to accomplish is to clear the component occurrence names, so they use the default setting. I wasn't sure if I could access the solid body of the part through the component occurrence or if I need to cycle each part and open the document so I can access it. I'm in an exploratory phase and so my approach looks questionable, trust me I'm answering some of my own questions. haha 

 

I was able to access the document through the component occurrence. From the part document I was able to create a part component definition which as shown above gave me access to the clear appearance override. When the program finished I opened one of the parts in the assembly and checked the solid body appearance and it said "As Part". Success!

 

' Restablish the occurance document as a part document
Dim LocalDoc as Inv.PartDocument = OccDoc
' Get the Component Definition from the Part Doc
Dim LocalDef as Inv.PartComponentDefinition = LocalDoc.ComponentDefinition
' Remove the material and appearances to change solid body appearance
LocalDef.Material.Delete()
LocalDef.ClearAppearanceOverrides()

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

Post to forums  

Autodesk Design & Make Report