Hi all
I have inherited a large assembly model about 200 parts or so. including 7000+ lines of code and everything is running fine. One problem. We have recently changed from Inventor 2020 to Inventor 2024.
This removes our previous possibility to use Level of Detail to make different views of same model.
As standard our model works in the Design View "iLogic" but i want a design view called "K-Structure" i can use for production drawings where some parts are invisible as a standard and other parts follow the “Main View” (My iLogic Design View)
Is there a smart way how to change the visibility in more than one design view on the same time without having to changing back and forth between the 2 Desing Views?
I currently have the following code snippet to jump back and forth between the 2 Design Views
Thanks in Advance
Dim odoc As Document Dim ocompdef As ComponentDefinition odoc = ThisApplication.ActiveDocument ocompdef = odoc.ComponentDefinition Try ocompdef.RepresentationsManager.DesignViewRepresentations.Item("K-Structure").Activate ocompdef.RepresentationsManager.DesignViewRepresentations.Item("iLogic").Activate Catch MessageBox.Show("This viewrep does not exist", "Error") End Try
Solved! Go to Solution.
Hi all
I have inherited a large assembly model about 200 parts or so. including 7000+ lines of code and everything is running fine. One problem. We have recently changed from Inventor 2020 to Inventor 2024.
This removes our previous possibility to use Level of Detail to make different views of same model.
As standard our model works in the Design View "iLogic" but i want a design view called "K-Structure" i can use for production drawings where some parts are invisible as a standard and other parts follow the “Main View” (My iLogic Design View)
Is there a smart way how to change the visibility in more than one design view on the same time without having to changing back and forth between the 2 Desing Views?
I currently have the following code snippet to jump back and forth between the 2 Design Views
Thanks in Advance
Dim odoc As Document Dim ocompdef As ComponentDefinition odoc = ThisApplication.ActiveDocument ocompdef = odoc.ComponentDefinition Try ocompdef.RepresentationsManager.DesignViewRepresentations.Item("K-Structure").Activate ocompdef.RepresentationsManager.DesignViewRepresentations.Item("iLogic").Activate Catch MessageBox.Show("This viewrep does not exist", "Error") End Try
Solved! Go to Solution.
Solved by ashSPTSS. Go to Solution.
Hi, interesting question because i do the same in my configurator and i was wondering if it actually was possible.
I tried it with an objectcollection but it only works if you activate that specific view represention.
Dim Invapp As Inventor.Application = ThisApplication
Dim oAsmDoc As AssemblyDocument = invapp.ActiveDocument
Dim oAsmCompDef As AssemblyComponentDefinition = oAsmDoc.ComponentDefinition
Dim oRepMan As RepresentationsManager = oAsmCompDef.RepresentationsManager
Dim oDesignViews As DesignViewRepresentations = oRepMan.DesignViewRepresentations
Dim oIsoView As DesignViewRepresentation = oDesignViews.Item("ISO")
Dim oExtView As DesignViewRepresentation = oDesignViews.Item("EXT VIEW")
Dim oColl As ObjectCollection = Invapp.TransientObjects.CreateObjectCollection
oColl.Add(oAsmCompDef.Occurrences(4))
oColl.Add(oAsmCompDef.Occurrences(7))
oExtView.Activate
oExtView.SetVisibilityOfOccurrences(oColl, True)
oisoview.Activate
oIsoView.SetVisibilityOfOccurrences(oColl, True)
Hi, interesting question because i do the same in my configurator and i was wondering if it actually was possible.
I tried it with an objectcollection but it only works if you activate that specific view represention.
Dim Invapp As Inventor.Application = ThisApplication
Dim oAsmDoc As AssemblyDocument = invapp.ActiveDocument
Dim oAsmCompDef As AssemblyComponentDefinition = oAsmDoc.ComponentDefinition
Dim oRepMan As RepresentationsManager = oAsmCompDef.RepresentationsManager
Dim oDesignViews As DesignViewRepresentations = oRepMan.DesignViewRepresentations
Dim oIsoView As DesignViewRepresentation = oDesignViews.Item("ISO")
Dim oExtView As DesignViewRepresentation = oDesignViews.Item("EXT VIEW")
Dim oColl As ObjectCollection = Invapp.TransientObjects.CreateObjectCollection
oColl.Add(oAsmCompDef.Occurrences(4))
oColl.Add(oAsmCompDef.Occurrences(7))
oExtView.Activate
oExtView.SetVisibilityOfOccurrences(oColl, True)
oisoview.Activate
oIsoView.SetVisibilityOfOccurrences(oColl, True)
Hi guys. I have never seen or heard of a way to edit the settings of more than one DVR (DesignViewRepresentation) at a time. I do not know of any Excel worksheet, table, or XML String type access to them where they could all be edited in one place, like ModelStates can. I do know about the DesignViewRepresentation.DesignViewInfo property, but that is ReadOnly, so no luck there. I would not want to have to edit XML code for something as seemingly simple as this anyways. Maybe this is something you could check in the Inventor Ideas forum for, and if no one else has posted about it, you could create a post in there about it. If DVR's had some sort of table (like ModelStateTable) type access, or more control over editing just one, multiple, or all at the same time (similar to edit scope), that could be pretty useful and efficient in various situations.
One efficiency trick I sometimes use when two DVR's share many identical settings, is to set the one the way I want it, then create (or Delete, then recreate) the second one using the Copy method, then switch to that second one, then change just the remainder of its settings the way I want. But that only effects to DVR's, and still involved activating both, so not really a solution. Taking advantage of the HideAll or ShowAll methods can sometimes help in situations where you only want one (or very few) components visible/invisible, but still must activate the DVR you want to edit.
Edit: I just created an Inventor Idea post for this ability, because it does sound super useful and should be a fairly popular topic. The link to that Idea post is below. The more people vote for it, the more likely it may be included in a future release of Inventor.
Wesley Crihfield
(Not an Autodesk Employee)
Hi guys. I have never seen or heard of a way to edit the settings of more than one DVR (DesignViewRepresentation) at a time. I do not know of any Excel worksheet, table, or XML String type access to them where they could all be edited in one place, like ModelStates can. I do know about the DesignViewRepresentation.DesignViewInfo property, but that is ReadOnly, so no luck there. I would not want to have to edit XML code for something as seemingly simple as this anyways. Maybe this is something you could check in the Inventor Ideas forum for, and if no one else has posted about it, you could create a post in there about it. If DVR's had some sort of table (like ModelStateTable) type access, or more control over editing just one, multiple, or all at the same time (similar to edit scope), that could be pretty useful and efficient in various situations.
One efficiency trick I sometimes use when two DVR's share many identical settings, is to set the one the way I want it, then create (or Delete, then recreate) the second one using the Copy method, then switch to that second one, then change just the remainder of its settings the way I want. But that only effects to DVR's, and still involved activating both, so not really a solution. Taking advantage of the HideAll or ShowAll methods can sometimes help in situations where you only want one (or very few) components visible/invisible, but still must activate the DVR you want to edit.
Edit: I just created an Inventor Idea post for this ability, because it does sound super useful and should be a fairly popular topic. The link to that Idea post is below. The more people vote for it, the more likely it may be included in a future release of Inventor.
Wesley Crihfield
(Not an Autodesk Employee)
Hi
Is it posible to change 2 model states at the same time using iLogic?
The problem im facing is that the changes being made using my iLogic code is only effecting the Primary model state and what was set to Bom Structure as reference and or suppresed in the other level of detail before converting from Inventor 2020 to 2024.
I have been told that it would be close to imposible to make the same updates in both model states at the same time.
Im trying to work on a small for loop of code looking on all components where visibility is on in one Design view and then go to my secondary design view to change it to the same in my primary design view (For me its my iLogic view)
Hi
Is it posible to change 2 model states at the same time using iLogic?
The problem im facing is that the changes being made using my iLogic code is only effecting the Primary model state and what was set to Bom Structure as reference and or suppresed in the other level of detail before converting from Inventor 2020 to 2024.
I have been told that it would be close to imposible to make the same updates in both model states at the same time.
Im trying to work on a small for loop of code looking on all components where visibility is on in one Design view and then go to my secondary design view to change it to the same in my primary design view (For me its my iLogic view)
Hi @ashSPTSS. This is another one that does not have a simple Yes/No answer. Yes, it would be possible to modify two different ModelState objects in the same way, at the same time...if those were the only two ModelStates present in the file, and we set the member edit scope to all members / factory scope. However, if there were more / other ModelStates present besides the two you want to edit, then there is 'technically' not a way to only edit two (out of more than two) ModelStates at the same time, without editing all of them. But, we can edit multiple of them by code in the same ways pretty quickly, such as in a loop / iteration. There are two main ways to edit multiple, but not all, ModelStates the same way by code. One way would be to get the collection of ModelStates, then iterate through them, check if each one is one you want to edit, and if so activate it, then make the edits you want while it is active, then advance to the next ModelState in the loop, and so on. Sometimes a document update may be needed between editing one before the next. The other main way to edit multiple, but not all ModelStates, is to do so through the ModelStateTable or Excel worksheet representation of that table. Yes, we can do that by code too, but of course it is a bit more complicated to do by code than it is to do manually. In this scenario, each row in the table represents another ModelState, then each column represents some detail or difference of each ModelState. As you would imagine, we would have to navigate this table by its rows & columns to access the individual cells that we want to change the values of, which can seem simple to say, but not always as simple to do, depending on what types of things you are trying to do / change. For instance, if you plan on changing the value of an iProperty in the table, then you must also know the name of the PropertySet that specific property belongs to, because that PropertySet name is often part of the text within the 'Header' of the column, within [] characters, right after the name of the property, like what you see when you manually open the ModelState table in Excel. However, before you can do either method of editing multiple ModelStates, you must first make sure you have a reference to the 'factory' document version of the file. This is just the Document that is associated with (under the control of) the ModelState that is currently active in that file.
Wesley Crihfield
(Not an Autodesk Employee)
Hi @ashSPTSS. This is another one that does not have a simple Yes/No answer. Yes, it would be possible to modify two different ModelState objects in the same way, at the same time...if those were the only two ModelStates present in the file, and we set the member edit scope to all members / factory scope. However, if there were more / other ModelStates present besides the two you want to edit, then there is 'technically' not a way to only edit two (out of more than two) ModelStates at the same time, without editing all of them. But, we can edit multiple of them by code in the same ways pretty quickly, such as in a loop / iteration. There are two main ways to edit multiple, but not all, ModelStates the same way by code. One way would be to get the collection of ModelStates, then iterate through them, check if each one is one you want to edit, and if so activate it, then make the edits you want while it is active, then advance to the next ModelState in the loop, and so on. Sometimes a document update may be needed between editing one before the next. The other main way to edit multiple, but not all ModelStates, is to do so through the ModelStateTable or Excel worksheet representation of that table. Yes, we can do that by code too, but of course it is a bit more complicated to do by code than it is to do manually. In this scenario, each row in the table represents another ModelState, then each column represents some detail or difference of each ModelState. As you would imagine, we would have to navigate this table by its rows & columns to access the individual cells that we want to change the values of, which can seem simple to say, but not always as simple to do, depending on what types of things you are trying to do / change. For instance, if you plan on changing the value of an iProperty in the table, then you must also know the name of the PropertySet that specific property belongs to, because that PropertySet name is often part of the text within the 'Header' of the column, within [] characters, right after the name of the property, like what you see when you manually open the ModelState table in Excel. However, before you can do either method of editing multiple ModelStates, you must first make sure you have a reference to the 'factory' document version of the file. This is just the Document that is associated with (under the control of) the ModelState that is currently active in that file.
Wesley Crihfield
(Not an Autodesk Employee)
Hi @WCrihfield and @KurtDR
Thanks fo showing interrest in this subject.
I ended up solving the issure with adding an external rule to my collection. and the following code
Sub Main _UpdateKView End Sub Sub _UpdateKView Dim odoc As Document odoc = ThisApplication.ActiveDocument Dim ocompdef As ComponentDefinition ocompdef = odoc.ComponentDefinition Info("UpdateKVievs") Try ThisApplication.ScreenUpdating = False iLogicVb.RunExternalRule("SetSubKViewRep") Catch ex As Exception debug("Failed updating DesignView(s)" & ex.ToString()) Finally ThisApplication.ScreenUpdating = True End Try ocompdef.RepresentationsManager.DesignViewRepresentations.Item("K-Structure").Activate ' Component excluded in Vent Component.Visible("IsolationHousingPlateShaftSide") = False
'... More components excluded ocompdef.RepresentationsManager.DesignViewRepresentations.Item("iLogic").Activate InventorVb.DocumentUpdate(False) MessageBox.Show("K-Structure Drawing View Updated", "Drawing View", MessageBoxButtons.OK) End Sub Sub Info(txt As String) debug(txt & " (info)") End Sub Sub debug(txt As String) Trace.WriteLine("NTI : " & txt) End Sub
The external rule uses the following code
My CommonRules include features like the Trace.WriteLine ect.
AddVbFile "CommonRules"
Dim RepName="iLogic" Dim RepName1="K-Structure" Dim doc As AssemblyDocument = ThisDoc.Document 'TraceLine("SetSubKViewRep is running in " & doc.FullFileName) Try doc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations.Item(RepName).Activate doc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations.Item(RepName).Locked=False doc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations.Item(RepName1).Activate doc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations.Item(RepName1).Locked=False Catch ' TraceLine("No DV / Couldn't set DV '" & RepName & "' in " & doc.FullFileName) Return End Try Dim oOcc As ComponentOccurrence For Each oOcc In doc.ComponentDefinition.Occurrences doc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations.Item(RepName).Activate Dim visib As Boolean=Component.Visible(oOcc.Name) If oOcc.Name.StartsWith("ATT_") Then visib=True End If If oOcc.Name=("TT_SquareFlange") Or oOcc.Name=("HousingStiffeners_Skel") Then visib=False End If doc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations.Item(RepName1).Activate oOcc.Visible= visib If visib And oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then Try oOcc.SetDesignViewRepresentation("iLogic", True) Catch End Try End If Next
Hi @WCrihfield and @KurtDR
Thanks fo showing interrest in this subject.
I ended up solving the issure with adding an external rule to my collection. and the following code
Sub Main _UpdateKView End Sub Sub _UpdateKView Dim odoc As Document odoc = ThisApplication.ActiveDocument Dim ocompdef As ComponentDefinition ocompdef = odoc.ComponentDefinition Info("UpdateKVievs") Try ThisApplication.ScreenUpdating = False iLogicVb.RunExternalRule("SetSubKViewRep") Catch ex As Exception debug("Failed updating DesignView(s)" & ex.ToString()) Finally ThisApplication.ScreenUpdating = True End Try ocompdef.RepresentationsManager.DesignViewRepresentations.Item("K-Structure").Activate ' Component excluded in Vent Component.Visible("IsolationHousingPlateShaftSide") = False
'... More components excluded ocompdef.RepresentationsManager.DesignViewRepresentations.Item("iLogic").Activate InventorVb.DocumentUpdate(False) MessageBox.Show("K-Structure Drawing View Updated", "Drawing View", MessageBoxButtons.OK) End Sub Sub Info(txt As String) debug(txt & " (info)") End Sub Sub debug(txt As String) Trace.WriteLine("NTI : " & txt) End Sub
The external rule uses the following code
My CommonRules include features like the Trace.WriteLine ect.
AddVbFile "CommonRules"
Dim RepName="iLogic" Dim RepName1="K-Structure" Dim doc As AssemblyDocument = ThisDoc.Document 'TraceLine("SetSubKViewRep is running in " & doc.FullFileName) Try doc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations.Item(RepName).Activate doc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations.Item(RepName).Locked=False doc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations.Item(RepName1).Activate doc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations.Item(RepName1).Locked=False Catch ' TraceLine("No DV / Couldn't set DV '" & RepName & "' in " & doc.FullFileName) Return End Try Dim oOcc As ComponentOccurrence For Each oOcc In doc.ComponentDefinition.Occurrences doc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations.Item(RepName).Activate Dim visib As Boolean=Component.Visible(oOcc.Name) If oOcc.Name.StartsWith("ATT_") Then visib=True End If If oOcc.Name=("TT_SquareFlange") Or oOcc.Name=("HousingStiffeners_Skel") Then visib=False End If doc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations.Item(RepName1).Activate oOcc.Visible= visib If visib And oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then Try oOcc.SetDesignViewRepresentation("iLogic", True) Catch End Try End If Next
Can't find what you're looking for? Ask the community or share your knowledge.