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: 

The illumination is made of sheet metal.

12 REPLIES 12
SOLVED
Reply
Message 1 of 13
negutorthik
316 Views, 12 Replies

The illumination is made of sheet metal.

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?

12 REPLIES 12
Message 2 of 13
WCrihfield
in reply to: negutorthik

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.

WCrihfield_0-1695653765060.png

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 13
negutorthik
in reply to: WCrihfield

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 .

Message 4 of 13
negutorthik
in reply to: WCrihfield

I apologize for the auto translation of "I need"

Message 5 of 13
aurel_e
in reply to: negutorthik

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()
​

 


 

Message 6 of 13
WCrihfield
in reply to: negutorthik

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

EESignature

(Not an Autodesk Employee)

Message 7 of 13
negutorthik
in reply to: aurel_e

Great! That's what we need. It would be nice to also return the color.

Message 8 of 13
negutorthik
in reply to: WCrihfield

WCrihfield . Nothing happens. It doesn't seem to work.

Message 9 of 13
aurel_e
in reply to: negutorthik

I know... what you can do:
If you have noticed, it creates a View Rep called "Sheet Metal Color". When you finish you could delete that View Rep.
Message 10 of 13
negutorthik
in reply to: aurel_e

Thank you very much!

Message 11 of 13
WCrihfield
in reply to: negutorthik

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

EESignature

(Not an Autodesk Employee)

Message 12 of 13
negutorthik
in reply to: WCrihfield

I tried again. It works ! At the slightest movement of the mouse, it turns off. That's why I didn't notice right away

Message 13 of 13
negutorthik
in reply to: WCrihfield

Thank you very much!!!👍

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report