How to gray out part (provided by others) using ilogic in inventor drawing

How to gray out part (provided by others) using ilogic in inventor drawing

Anonymous
Not applicable
1,235 Views
12 Replies
Message 1 of 13

How to gray out part (provided by others) using ilogic in inventor drawing

Anonymous
Not applicable

I'm trying to write ilogic codes that when I run, they "gray-out" (color code is 144, 144, 144) the parts or assemblies provided by others. 

Right now, what I'm doing is selecting individual part/assembly, right-click, and change the color manually. I want to reduce time creating drawings. Any help would be much appreciated.

 

0 Likes
1,236 Views
12 Replies
Replies (12)
Message 2 of 13

Anonymous
Not applicable

What do you have so far?

0 Likes
Message 3 of 13

Anonymous
Not applicable

I haven't written any code yet. This is my first attempt to program in ilogic. 

I'm thinking about  name the parts/assemblies, which provided by others, as "by others". Then in ilogic, write codes to gray-out any parts/assemblies that have names associated with "by others".

 

Something like this

PN_Name = iProperties.Value("Project", "Part Name")

If Component.Value("Project", "Part Name") = "by others" Then
 Component.Color("Part Name")= "Gray"
End if

 

0 Likes
Message 4 of 13

Anonymous
Not applicable

Ok. 

 

How do you want to identify the parts that are by others?  Will they always be by others? 

 

If they are always By Others, then i don't think you need any customization.  When creating the part that is "By Others", simply set the appearance at the part level. 

0 Likes
Message 5 of 13

Anonymous
Not applicable
What I design are structure systems which are usually located on top of a
building or a steel pole.

Most of the time the steel structure is designed and provided by others and
each model would have a different steel structure. Sometimes, customers
want us to draw an existing rooftop to see how the model would fit, and we
want to gray-out (dim-out) the existing structures for better visualization.

What I've been doing is right-clicked on each part/assembly in the part
browser and change the color in the properties. Thus, I want to create an
ilogic rule that when I run, all the parts/assembly/components provided by
others will be grayed-out.
0 Likes
Message 6 of 13

Anonymous
Not applicable

Are you trying to do this in drawings or assemblies?

0 Likes
Message 7 of 13

Anonymous
Not applicable

in the drawing

0 Likes
Message 8 of 13

Anonymous
Not applicable

Can you share a drawing that has what you want this to look like?  Also, would the reference BOM structure work for you?  It automatically comes in as dashed lines in drawing views, and is excluded in your BOM. 

 

0 Likes
Message 9 of 13

Anonymous
Not applicable

Here is an example (attached pic). The grayed parts are provided by others.

I'm not sure I understand what you mean by referencing the BOM structure.

 

 

0 Likes
Message 10 of 13

JamieVJohnson2
Collaborator
Collaborator

How about some code (vb.net)

 Public Sub SetComponentsReference()
        Dim strComponent As String = InputBox("Insert Component Name")
        Dim strLayer As String = InputBox("Enter in layer to use:", "Change Component Layer", "Reference (ANSI)")
        Dim layer As Inventor.Layer = Nothing
        If Not String.IsNullOrEmpty(strComponent) Then
            GetInventorApplication()
            If invApp IsNot Nothing Then
                If invApp.ActiveDocumentType = DocumentTypeEnum.kDrawingDocumentObject Then
                    Dim invdoc As Inventor.DrawingDocument = invApp.ActiveDocument
                    Dim trans As Inventor.Transaction = invApp.TransactionManager.StartTransaction(invdoc, "Change Componet Layer")
                    For Each mlayer As Inventor.Layer In invdoc.StylesManager.Layers
                        If mlayer.Name = "Reference (ANSI)" Then
                            layer = mlayer
                            Exit For
                        End If
                    Next
                    If layer IsNot Nothing Then
                        For Each mSheet As Inventor.Sheet In invdoc.Sheets
                            MsgBox(mSheet.Name & " Start")
                            Dim ioc As Inventor.ObjectCollection = invApp.TransientObjects.CreateObjectCollection
                            For Each drView As Inventor.DrawingView In mSheet.DrawingViews
                                Dim vdoc As Inventor.Document = drView.ReferencedDocumentDescriptor.ReferencedDocument
                                If vdoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
                                    Dim aDoc As Inventor.AssemblyDocument = vdoc
                                    GetComponentSegments(strComponent, drView, aDoc.ComponentDefinition.Occurrences, ioc)
                                End If
                            Next
                            mSheet.ChangeLayer(ioc, layer)
                            mSheet.Update()
                            MsgBox(mSheet.Name & " Updated")
                        Next
                    End If
                    trans.End()
                End If
            End If
        End If
    End Sub

sets components to a layer (create a custom layer of your own, and change code to default to it).  Components found in all views of all sheets of active document (by component occurrence name) aka load.ipt has occurrence name "load:1".  We use this to isolate components graphically without changing BOM properties.  Same can be done manually by right-clicking on object in view browser, and choosing select as edges, then changing layer.

Jamie Johnson : Owner / Sisu Lissom, LLC https://sisulissom.com/
0 Likes
Message 11 of 13

Anonymous
Not applicable

@JamieVJohnson2 I tried your code in ilogic. It gave me error messages. I tried to debugged it, but couldn't get it to work. I assume your codes are used for VBA environment. Is it right?

Thanks

0 Likes
Message 12 of 13

JamieVJohnson2
Collaborator
Collaborator

Most of my code posted here is from VB.Net written in VisualStudio, but the iLogic editor can read vb.Net code pretty well.  However VBA (think macros system) handles things differently (VBA - visual basic, for applications, version 6-, VB.Net - visual basic, for everything .net, version 7+)  There are syntax changes like the use of 'Set' that are no longer used in VB.Net.

 

Also in VB.Net I had to write my own routine to get the Inventor Application instance (GetInventorApplication).  In iLogic you can just use invapp=ThisApplication (which actually came from VBA, MS Office uses it too.)  I didn't post the details of that function, so that could be where your first error is found.  

Jamie Johnson : Owner / Sisu Lissom, LLC https://sisulissom.com/
0 Likes
Message 13 of 13

Anonymous
Not applicable

@JamieVJohnson2 thank you. I will play around with it.

0 Likes