iLoigc rule to create sheet with views.

iLoigc rule to create sheet with views.

Brian.Price
Advocate Advocate
2,013 Views
24 Replies
Message 1 of 25

iLoigc rule to create sheet with views.

Brian.Price
Advocate
Advocate

Hello,

 

Right now this is more of a how to approach question. My skill level with ilogic isn't very high and I could probably do with some VBA classes, but I am very good at reverse engineering the code and understanding its use and function.

 

My current thinking is to use the BOM to get the information I need to make this new rule run.

 

I created a rule that will allows the user to select a file, in the open file window, that will then create a new sheet with views automatically placed in locations along with a parts list, title block, border, and automated center lines. It will also allow pages to be placed manually as well.

 

What I want to do is take this to the next level by Inventor accessing the sub assemblies in the Structured BOM and generating those sheets for each sub assembly. One issue I see is that with a few hundred sub assemblies I don't want them all in one drawing file as that will make Inventor cry. I was thinking of adding a variable parameter to decide which sub assemblies to add based on BOM item numbers. Example: If parameter is >=1 and <=50 it would create sheets for items 1-50.

 

The things I am looking for is the API functions for Inventors BOM. (I could honestly use a general list of API for inventor)

How to retrieve the file path from the BOM and have the rule run for each row of the BOM.

Make the output variable depending on the range of item numbers.

 

This is a pretty big undertaking for me and I appreciate any help or input.

0 Likes
Accepted solutions (1)
2,014 Views
24 Replies
Replies (24)
Message 21 of 25

Brian.Price
Advocate
Advocate

This is one of the issues I have been running into. With the assembly bom the file path is available. Trying to get that information from a parts list seems to be more difficult. I do wonder if it would be better to run this from the assembly and how to do that.

0 Likes
Message 22 of 25

WCrihfield
Mentor
Mentor

We could still work with the Assembly file's BOM from the open and activated drawing, if that's the route you want to take.  But trying to work only with the PartsList to accomplish this, may be a dead end.  There may be a way to combine using both, if it's critical.  There is likely a way to compare the file name String retrieved from the PartsList with a FullFileName String retrieved from looping through the Assembly's BOM or Occurrences, to get its path.  It would likely be a far longer & more complex code.

Are you using DesignViewRepresentation to filter which components are listed in your PartsList.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 23 of 25

Brian.Price
Advocate
Advocate

I do use view reps from time to time for the parts lists filters.

If using the sheet one active assemblies BOM makes this easier I am all for it.

0 Likes
Message 24 of 25

WCrihfield
Mentor
Mentor

Hi @Brian.Price .  Here is the iLogic code which gets the FileName from the Column in the PartsList, then searches the Assembly side BOM for the matching FullFileName to go with it.

Now all that's left is the portion to create your drawing.  Just remember to put some code in there which checks to see if the Drawing File already exists, and asks you if you want to over write it.

Sub Main

Dim oDDoc As DrawingDocument = ThisDrawing.Document

Dim oADoc As AssemblyDocument = ThisDrawing.ModelDocument
Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition

Dim oBOM As BOM = oADef.BOM
oBOM.StructuredViewEnabled = True
Dim oStructuredBOMView As BOMView
For Each oBOMView As BOMView In oBOM.BOMViews
	If oBOMView.ViewType = BOMViewTypeEnum.kStructuredBOMViewType Then
		oStructuredBOMView = oBOMView
	End If
Next

Dim oPList As PartsList = oDDoc.Sheets.Item(1).PartsLists.Item(1)

Dim oFileNameCol As Integer
Dim i As Integer
For i = 1 To oPList.PartsListColumns.Count
	If oPList.PartsListColumns.Item(i).PropertyType = PropertyTypeEnum.kFilenamePartsListProperty Then
		oFileNameCol = i
	End If
	i = i + 1
Next

Dim oItemFileName As String
Dim oFullFileName As String
Dim oRow As PartsListRow
For Each oRow In oPList.PartsListRows
	oItemFileName = oRow.Item(oFileNameCol).Value
	MsgBox("PartsList Item FileName = " & oItemFileName)
	GetFullFileName(oStructuredBOMView, oItemFileName, oFullFileName) '< Function
	'You can comment this next line out after you get the next part working.
	MsgBox("oFullFileName = " & oFullFileName)
	'Place the remainder of you code to create the drawings here.
	'Or, perhaps use another Sub.
Next

End Sub

Function GetFullFileName(ByRef oStructuredBOMView As BOMView,ByRef oItemFileName As String,ByRef oFullFileName As String) As String
	Dim oRow As BOMRow
	Dim oDoc1 As Document
	For Each oRow In oStructuredBOMView.BOMRows
		oDoc1 = oRow.ComponentDefinitions.Item(1).Document
		If InStr(oDoc1.FullFileName, oItemFileName) > 0 Then
			oFullFileName = oDoc1.FullFileName
		End If
	Next
End Function

If this helps, Likes 👍 are appreciated.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 25 of 25

Anonymous
Not applicable

Hi @WCrihfield

Thanks for the tip. We have a good filing system in place to store all the components in the model. So we exclude the ones we don't want accordingly, by determining which folder it is stored in. Using the occurrences method can definitely be useful for future projects though. Thanks!   

0 Likes