Hi guys! Is it possible to come up with an iLogic rule that could enable and disable the illumination or transparency of milestones of sheet metal parts in the entire assembly? Any ideas?
Solved! Go to Solution.
Solved by WCrihfield. Go to Solution.
Solved by aurel_e. Go to Solution.
Can you please explain this in more detail? I am not sure what you mean by illumination or milestones. We can highlight components, if that is what you mean by illumination. We can also turn transparent property of assembly components on and off. But when would these things be needed? What are the conditions that must be met before a component would be highlighted/un-highlighted or the transparency status changed?
Edit: By the way, did you know that you can tell if a part is a regular part or a sheet metal part in an assembly by looking at the model browser node icon?
A regular part just shows a simple cube or small box as the browser node icon.
A sheet metal part has what looks like a folded over flange as the browser node icon.
Wesley Crihfield
(Not an Autodesk Employee)
You are absolutely right. You need to highlight the components. Before saving to DXF, you need to make sure that all the necessary components are converted into sheet metal. Therefore, you need to run the rule, translate the component if necessary and disable the rule, for example, with the "ESC" button. p.s. how the sign looks in the browser is known). when an assembly consists of several assemblies , it is not very convenient .
What about changing color to all sheet metal parts?
Something like this:
Dim topAsm As AssemblyDocument = ThisDoc.Document
Dim oAsmDef As AssemblyComponentDefinition = topAsm.ComponentDefinition
Dim trans As Transaction = ThisApplication.TransactionManager.StartTransaction(topAsm, "SHEET METAL COLOR")
Dim ucRep As DesignViewRepresentation
Try
ucRep = topAsm.ComponentDefinition.RepresentationsManager.DesignViewRepresentations("SHEET METAL COLOR")
Catch ex As Exception
ucRep = topAsm.ComponentDefinition.RepresentationsManager.DesignViewRepresentations.Add("SHEET METAL COLOR")
End Try
ucRep.Activate()
Dim knowOcc As Dictionary(Of String, Asset) = New Dictionary(Of String, Asset)
Dim leafOcc As ComponentOccurrencesEnumerator = oAsmDef.Occurrences.AllLeafOccurrences
Dim compOcc As ComponentOccurrence
For Each compOcc In leafOcc
Dim occDoc As Document = compOcc.Definition.Document
If (occDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}") Then
Dim occPropSet As PropertySet = occDoc.PropertySets.Item("Design Tracking Properties")
Dim propert As [Property] = occPropSet.Item("Part Number")
Dim occName As String = propert.Value
If (knowOcc.ContainsKey(occName)) Then
compOcc.Appearance = knowOcc.Item(occName)
Else
Dim uAppearance As Asset = topAsm.Assets.Add(AssetTypeEnum.kAssetTypeAppearance, "Generic", "appearances")
Dim uColor As ColorAssetValue = uAppearance.Item("generic_diffuse")
Dim RNG = 200
Dim RNG1 = 120
Dim RNG2 = 255
uColor.Value = ThisApplication.TransientObjects.CreateColor(RNG, RNG1, RNG2)
compOcc.Appearance = uAppearance
knowOcc.Add(occName, uAppearance)
End If
End If
Next
trans.End()
Here is an iLogic rule that will iterate down through all levels of the assembly, and add all of the sheet metal components to a HighlightSet of the main assembly. I set the color of the set to Red, just as an example. I am not sure which of the parts which are not currently sheet metal parts may need to be converted into sheet metal parts though. But that conversion is relatively simple to do by code too, if needed.
Sub Main
If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
MsgBox("An Assembly Document must be active for this rule to work. Exiting.", vbCritical, "")
Exit Sub
End If
Dim oADoc As AssemblyDocument = ThisDoc.Document
Dim oOccs As ComponentOccurrences = oADoc.ComponentDefinition.Occurrences
If oOccs.Count = 0 Then Exit Sub
oHLS = oADoc.CreateHighlightSet
oHLS.Color = ThisApplication.TransientObjects.CreateColor(255, 0, 0) 'Red
RecurseComponents(oOccs)
End Sub
Dim oHLS As Inventor.HighlightSet
Sub RecurseComponents(oComps As ComponentOccurrences)
If oComps Is Nothing OrElse oComps.Count = 0 Then Exit Sub
For Each oComp As ComponentOccurrence In oComps
If oComp.Suppressed Then Continue For
If TypeOf oComp.Definition Is SheetMetalComponentDefinition Then
oHLS.AddItem(oComp)
End If
If oComp.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
RecurseComponents(oComp.SubOccurrences)
End If
Next
End Sub
If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield
(Not an Autodesk Employee)
That's odd, because I tested my code on a large assembly just before I posted it here, and it seemed to work just fine for me. After I ran the rule, there were several parts that had all of their edges highlighted in red, even parts down within sub assemblies. Sometimes highlightsets can be a little unpredictable though. Sometimes the effect will last for a while, even while you interact with some stuff in the assembly. Other times it seems to disappear almost instantly. Something to do with the document updating or refreshing the screen or something like that. I know that if I click Rebuild All, or double click on a component to edit it, or otherwise do anything to cause the document to update, all of the highlight effect will be gone. It has its uses, benefits, pros and cons.
Wesley Crihfield
(Not an Autodesk Employee)
I tried again. It works ! At the slightest movement of the mouse, it turns off. That's why I didn't notice right away
Can't find what you're looking for? Ask the community or share your knowledge.