Part Sketch Visibilty - Assemblie Level.

Part Sketch Visibilty - Assemblie Level.

Luis_Pacheco_3D
Advocate Advocate
362 Views
7 Replies
Message 1 of 8

Part Sketch Visibilty - Assemblie Level.

Luis_Pacheco_3D
Advocate
Advocate

Hi everyone, I´m trying to turn on the visibility of a part sketch at the assembly level.  (Image)

 

Luis_Pacheco_3D_0-1762959614573.png

 

The rule I created always overrides the visibility in the part, keeping it invisible at the assembly level.

 

I would appreciate it if someone could help me with this.

 

0 Likes
363 Views
7 Replies
Replies (7)
Message 2 of 8

WCrihfield
Mentor
Mentor

Hi @Luis_Pacheco_3D.  Properly controlling the visibility of lower level stuff from a higher level assembly by code can potentially be a complex task/project.  My advice would be to properly utilize the view representations in both the lower level model files, and in the assembly itself.  They are what record things like object visibility (hiding or isolating), and appearances / colors.  By default, parts only have one view representation...the 'Master' or '[Primary]' one, which is Locked.  But we can create new, custom ones also.  For example, while each one is active, the part could be a different appearance/color, different work features or sketches could be visible/hidden, certain bodies in a multi-body part could be visible/hidden, and so on.  Then, when we place an assembly component into an assembly that references that part, we can set that component occurrence to one of those specific view representations, to make it look exactly that way.

So, in your case, you could open that part, ensure that a custom view representation exists, and is 'active', then turn on the visibility of that sketch, and make sure the visibility and appearance of everything else in the part is the way you want it, then optionally switch back to the originally active view representation before saving the part.  Then back at the assembly level, get the component representing that part, and set its view representation to the custom one in the part where that sketch is visible in it.

By code, those view representations are DesignViewRepresentations (the collection) and DesignViewRepresentation (a single one), and obtained from the RepresentationsManager through its RepresentationsManager.DesignViewRepresentations property, or its RepresentationsManager.ActiveDesignViewRepresentation property.  And we get the RepresentationsManager from the ComponentDefinition (AssemblyComponentDefinition.RepresentationsManager 0r PartComponentDefinition.RepresentationsManager).

Trying to control the visibility of things like that in lower level components from an assembly can be chaotic without  this without involving the view representations.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 8

Luis_Pacheco_3D
Advocate
Advocate

I’m working with Inventor 2023, and part files don’t support representation views. I think this feature only works with assemblies.

 

I’m not sure if I missed something, but thanks for your answer. I still have to turn on the visibility manually.

 

 

0 Likes
Message 4 of 8

WCrihfield
Mentor
Mentor

Hi @Luis_Pacheco_3D.  I'm pretty sure that parts have had the ability to include and use custom view representations for well over a decade, because I have been using them almost as far back as I can remember.  They are just not as prominent, or as commonly utilized at the part level as they are at the assembly level.  However, positional representations are unique to assemblies.  And back before ModelStates, the LODs (level of detail representations) were also unique to assemblies, but in 2022 they introduced ModelStates to both parts and assemblies, because although the old LODs primary purpose was recording suppression status, the newer ModelStates record much, much more now, including parameter values, property values, feature suppression, which assembly components are set to which ModelStates within an assembly, and more.  When I go back into the 2023 online API help, I can find the PartComponentDefinition.RepresentationsManager property there, and it says that it was introduced in version 2012.  From there we can bet to the RepresentationsManager.ActiveDesignViewRepresentation and RepresentationsManager.DesignViewRepresentations properties (both introduced in version 11).  Then the DesignViewRepresentation API object's help page also says it was introduced in version 11, which according to Wikipedia, came out in 2006.  iLogic itself only became available in the 2011 version, I think.

Manually, in the part's model tree, we don't see a folder named 'Representations', like we do in assemblies.  In assemblies we would have to expand the browser node for that Representations folder to see the view representations browser node, and the positional representations browser node.

WCrihfield_3-1763040050814.png

But in parts just see a structural/tree type symbol with the word "View" next to it, followed by a colon ":", then the name of the 'active' view representation.

WCrihfield_0-1763039027046.png

When we expand that browser node, we can then see the built-in, locked view representation that is present in every model document named "[Primary]", and used to be named "Master" in versions prior to 2022.  If we then right-click on the main views browser node, then choose 'New' from the context menu, we can create a new/custom view representation.  I have made a custom view representation directly within all of my part and assembly type templates named either "Default" or "DEFAULT", and made sure it is the active one when saved, that way every new part I create from any of my templates already has that custom view representation in it that will properly record the way I want that model file to look in all assemblies that I may put it into later, when I set the component to that view representation.  This small preparation has saved our company an incalculable amount of time and countless headaches over thee years since I implemented it.

WCrihfield_1-1763039691429.png WCrihfield_2-1763039775298.png

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 8

Luis_Pacheco_3D
Advocate
Advocate

Thanks again for your answer. I’m aware of the View option — I created a new view in the part and turned on the sketch visibility.

Luis_Pacheco_3D_0-1763052269225.png

 

However, in the assembly environment, the part only shows Model States; the View option seems to work only in IDW files.

Luis_Pacheco_3D_2-1763052440561.png

 

Luis_Pacheco_3D_1-1763052418040.png

 

I can’t find a way to achieve what I want. If I’ve missed something, my apologies. Thanks again for your help.

 

0 Likes
Message 6 of 8

WCrihfield
Mentor
Mentor

Hi @Luis_Pacheco_3D.  It is true that you do not see the 'Views' browser node under assembly components in the model tree within an assembly.  However, if you select the assembly component, either by selecting its browser node in the model tree, or by selecting it in the model window, then right-click, you will see the term "Representation..." in the context menu.  When you click that, you will see the usual small pop-up dialog where you can specify ModelState, view representation, and potentially positional representation (if it is a sub-assembly).  This is where you can manually set the view representation, and potentially the positional representation, if necessary.  By code, we can use the ComponentOccurrence.SetDesignViewRepresentation method to 'set' that view representation the way we want it.  Checking which view representation a component is currently set to is also possible by code, but there is a quirk to it though.  There is a property of the component like 'ComponentOccurrence.ActiveDesignViewRepresentation, but it is 'hidden' in some versions of Inventor, including 2023.  It is still there, and still works, just hidden from the Intellisense suggestions and the online help documentation.  It seems to have just been a hiccup or  slight mistake at some point, but it was pointed out and fixed later.  It can be seen in the 2020 version (ComponentOccurrence.ActiveDesignViewRepresentation), then goes missing, then shows up again in the 2026 version (ComponentOccurrence.ActiveDesignViewRepresentation).  Then there is the ComponentOccurrence.IsAssociativeToDesignViewRepresentation property, which it says is 'Read/Write' in the 2023 version, but I think it is only appropriate to 'change' its value to False, because I doubt if setting it to True would work the way you intended.  If we want to set that to True, we should use the SetDesignViewRepresetation method, and set the third input to True.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 7 of 8

hollypapp65
Collaborator
Collaborator

View Rep need to be setup in each file.

Start with the file with sketch you want to show.

One View Rep with sketch not visible.

One View Rep with sketch visible.

Then you'll need same View Rep in each assembly.  Make sure each View Rep use correct View Rep from the file before.

 

Same for Pos Rep.

0 Likes
Message 8 of 8

WCrihfield
Mentor
Mentor

An important detail in this overall process that is easy to miss, or difficult to learn by experience, is the following behavior.  (touched upon in @hollypapp65 last reply, but expanded on here)

  • When setting a component occurrence (or multiple of them) to specific view representations, those settings are being recorded by the currently 'active' view representation within the active assembly itself.  So, your main/active assembly can have multiple view representations, and while each assembly view rep. is active, those settings (which view rep each top level component occurrence is set to) can be set differently, and will be shown that way.
  • So, when specifying which view reps you want the components to be set to, be mindful of which view rep is active in the current/active assembly also, because those choices/settings are being recorded by that specific one only.
  • If the 'active' view representation in the 'active' document is a 'Locked' one, like the 'Master'/'[Primary]' one, then your visibility changes (show/hide) and appearance/color related changes, will not be recorded by it.  So, make sure you have a custom one active before making those types of changes.

And I apologize if I am over explaining stuff that you already know about.  It can be difficult to determine how much others may already know, so it is always a balancing act. 😉

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes