DRL Custom Row

DRL Custom Row

ndillner343SKL
Enthusiast Enthusiast
321 Views
2 Replies
Message 1 of 3

DRL Custom Row

ndillner343SKL
Enthusiast
Enthusiast

Hello, I'm new to iLogic when it comes to drawings and I don't even know where to start with this one. So I'm hoping someone here can help! I'm using the following code to create a drawing reference list within the drawing. Is there a way to insert a custom part, a custom row within the DRL? Item No, Description, and Drawing are the 3 rows I'm using. 

 

Thank you for your time!

 

Sub DRL()
	Dim oDrawingDoc As DrawingDocument
	oDrawingDoc = ThisApplication.ActiveDocument

	Dim oSheet As Sheet
	oSheet = oDrawingDoc.ActiveSheet

'	Detect If the template has a parts list
	Try 
		Dim oPartslistCheck As PartsList
		oPartslistCheck = oSheet.PartsLists(1)
		partslistpresent=True
	Catch
		partslistpresent=False
	End Try

	If partslistpresent=True
		'Delete the current parts list
		Dim oPartsList As PartsList
		oPartsList = oDrawingDoc.ActiveSheet.PartsLists.Item(1)
		oPartsList.Delete
	End If

	' a reference to the first drawing view on
	' the sheet. This assumes the first drawing
	' view on the sheet is not a draft view.
	Dim oDrawingView As DrawingView
	oDrawingView = oSheet.DrawingViews.Item(1)


	' a reference to the sheet's border
	Dim oBorder As Border
	oBorder = oSheet.Border

	' a reference to the sheet's title block
	Dim oTitleBlock As TitleBlock
	oTitleBlock = oSheet.TitleBlock

'	'['Update BOM to Structured View
'	InventorVb.DocumentUpdate()
'	' get model doc
'	Dim oModelDoc As Document
'	oModelDoc = ActiveSheet.View(oDrawingView.Name).ModelDocument
'	' get the BOM database
'	oBOM = oModelDoc.ComponentDefinition.BOM
'	' Make sure the BOM view is enabled
'	oBOM.StructuredViewEnabled = True
'	' Make sure the BOM first level is disabled
'	oBOM.StructuredViewFirstLevelOnly = False
'	' the delimiter for the BOM view
'	oBOM.StructuredViewDelimiter = "."
'	oModelDoc.Rebuild2
'	oModelDoc.Save
'	InventorVb.DocumentUpdate()
'	']

	'['Parts List
	Dim oPlacementPoint2 As Point2d
		xrev2 = oTitleBlock.RangeBox.MaxPoint.X - 0.62
		yrev2 = oTitleBlock.RangeBox.MaxPoint.Y + 0.998
		oPlacementPoint2 = ThisApplication.TransientGeometry.CreatePoint2d(xrev2, yrev2)
		
	' Create Parts List
	Dim oPartsList2 As PartsList
	oPartsList2 = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint2,PartsListLevelEnum.kStructuredAllLevels)
	']
	InventorVb.DocumentUpdate()
End Sub

 

0 Likes
Accepted solutions (1)
322 Views
2 Replies
Replies (2)
Message 2 of 3

A.Acheson
Mentor
Mentor
Accepted solution

 

You will first need to loop through the partslist rows. See example here from API Help, the first for loop sets up a counter (i) which you can then index the row between 1 and the total number of parts list rows called the count. At a certain index number you can insert the custom row snippet. You may need to identify an item in your partslist like a description or part number etc and for that you may need the column for loop also to catch a specific cell.

 

The sample is vba so do a find and replace for Set and replace with blank and replace sub.... with sub main. It might be easier to simply work with the sample and then integrate into your version.  

 

Insert custom parts list row

If you need help piecing it together just post the code your using and will be happy to help with advice. 

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 3 of 3

ndillner343SKL
Enthusiast
Enthusiast

I got it working! Thank you for pointing me in the right direction!