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?
Solved! Go to Solution.
Solved by WCrihfield. Go to Solution.
Solved by A.Acheson. Go to Solution.
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()
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
(Not an Autodesk Employee)
@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.