Ilogic rule at assembly to skip frame skeleton (or other) parts

Ilogic rule at assembly to skip frame skeleton (or other) parts

Anonymous
Not applicable
1,248 Views
5 Replies
Message 1 of 6

Ilogic rule at assembly to skip frame skeleton (or other) parts

Anonymous
Not applicable

Not a programmer so bear with me.

 

I have started a rule which is run in an assembly to create/format user parameters of parts referenced from the assembly; it throws an error with the reference frame which I do not need to format anyhow.  How do I exclude the rule from attempting a change to the reference frame?

 

Can "If Not TypeOf" be used with referenced documents or only occurrences?  Or is there another/better way?  

 

Part of my code below:

 

Public Sub Main() 
    ' Get the active assembly document. 
    Dim oAsmDoc As AssemblyDocument  
    oAsmDoc = ThisApplication.ActiveDocument 

    ' Iterate through all of the documents referenced by the assembly. 
    Dim oDoc As Document 
    For Each oDoc In oAsmDoc.AllReferencedDocuments
        ' Check to see if this is a part. 
        If oDoc.DocumentType = kPartDocumentObject Then 
            Dim oPartDoc As PartDocument
			oPartDoc = oDoc
			'Dim oRefDocName = oDoc.DisplayName
			       	'Dim oRefDocName = oDoc.DisplayName
					'MessageBox.Show(oRefDocName,"The component being updated is")
					CreateFormatG_L(oPartDoc, newParam, userParams)
					CreateFormatG_W(oPartDoc, newParam, userParams)
					CreateFormatG_H(oPartDoc, newParam, userParams)
					CreateFormatG_T(oPartDoc, newParam, userParams)
					'iProperties.Value(oModelName, "Project", "Vendor") = SheetNumber
		End If
    Next
	ThisDoc.Save
	MessageBox.Show("Finished updating Vendor Nos.")
End Sub

 

0 Likes
Accepted solutions (1)
1,249 Views
5 Replies
Replies (5)
Message 2 of 6

JaneFan
Autodesk
Autodesk
Accepted solution

Hey @Anonymous , 

 

Not sure whether I understand it correctly, but we can skip the frame skeleton by judging SurfaceBodies count if only skeleton parts have no solid bodies in your work space: 

Public Sub Main() 
    ' Get the active assembly document. 
    Dim oAsmDoc As AssemblyDocument  
    oAsmDoc = ThisApplication.ActiveDocument 

    ' Iterate through all of the documents referenced by the assembly. 
    Dim oDoc As Document 
    For Each oDoc In oAsmDoc.AllReferencedDocuments
        ' Check to see if this is a part. 
        If oDoc.DocumentType = kPartDocumentObject Then 
			If oDoc.ComponentDefinition.SurfaceBodies.Count > 0 Then 
	            Dim oPartDoc As PartDocument
				oPartDoc = oDoc
				'Dim oRefDocName = oDoc.DisplayName
		       	'Dim oRefDocName = oDoc.DisplayName
				'MessageBox.Show(oRefDocName,"The component being updated is")
				CreateFormatG_L(oPartDoc, newParam, userParams)
				CreateFormatG_W(oPartDoc, newParam, userParams)
				CreateFormatG_H(oPartDoc, newParam, userParams)
				CreateFormatG_T(oPartDoc, newParam, userParams)
				'iProperties.Value(oModelName, "Project", "Vendor") = SheetNumber
			End If 
		End If
    Next
	ThisDoc.Save
	MessageBox.Show("Finished updating Vendor Nos.")
End Sub

 




Jane Fan
Inventor/Fusion QA Engineer
Message 3 of 6

Anonymous
Not applicable

Thanks, that works great!

0 Likes
Message 4 of 6

Anonymous
Not applicable

Is it possible to query the Phantom Skeleton assembly present inside the Frame Main Assembly? I used the following condition.

If oOcc.Definition.BOMStructure = BOMStructureEnum.kPhantomBOMStructure Then

 But there are chances that users may use other Phantom assemblies inside the Frame assembly. In that case those might also get included in the process statements of the code. 

 

Can you help me with a statement to query only Frame Skeleton Assembly?

 

Thanks in advance...

0 Likes
Message 5 of 6

JaneFan
Autodesk
Autodesk

Hi @Anonymous , 

 

How about filter out the document which doesn't contain any surface body like this: 

Dim oOcc As ComponentOccurrence
    For Each oOcc In oAssyDoc.ComponentDefinition.Occurrences
        If oOcc.Definition.BOMStructure = BOMStructureEnum.kPhantomBOMStructure Then
            If oOcc.Definition.SurfaceBodies.Count = 0 Then
            End If
        End If
    Next



Jane Fan
Inventor/Fusion QA Engineer
Message 6 of 6

Anonymous
Not applicable
Thanks it works..
0 Likes