Insert parts list above titleblock

Insert parts list above titleblock

Anonymous
Not applicable
805 Views
4 Replies
Message 1 of 5

Insert parts list above titleblock

Anonymous
Not applicable

How can I change this code to insert the parts list above the title block

 

SyntaxEditor Code Snippet

If iProperties.Value("Summary", "Category") = "ASSEMBLY" Then 




iLogicVb.UpdateWhenDone = True   

' Set a reference to the drawing document.    ' This assumes a drawing document is active.    
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

'Set a reference to the active sheet.    
Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet    

' Set 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

Try
    oDrawingView = oSheet.DrawingViews(1)
Catch
    MessageBox.Show("No View found. Can not continue", "iLogic")
    Return 'return exits the rule
End Try

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

Dim oPlacementPoint As Point2d

If Not oBorder Is Nothing Then
    ' A border exists. The placement point        
    ' is the top-right corner of the border.        
    oPlacementPoint = oBorder.RangeBox.MaxPoint
Else
    ' There is no border      
    oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(20, 20)     
     
End If

Dim oPartslist As PartsList

Try        
    'look for the first parts list found on the sheet 
    'if succesful finding it, 
    'tell the user,then Do Nothing
    oPartslist = oSheet.PartsLists(1)
    MessageBox.Show("There is an existing Parts List", "iLogic")
    
Catch
    'if one is not found, Create it
    oPartsList = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint)
End Try
End If
0 Likes
Accepted solutions (2)
806 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
Accepted solution

Found something and played around with it.

adjust the offset to fit your title block. 

SyntaxEditor Code Snippet

If iProperties.Value("Summary", "Category") = "ASSEMBLY" Then 

iLogicVb.UpdateWhenDone = True   

' Set a reference to the drawing document.    ' This assumes a drawing document is active.    
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

'Set a reference to the active sheet.    
Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet    

' Set 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

Try
    oDrawingView = oSheet.DrawingViews(1)
Catch
    MessageBox.Show("No View found. Can not continue", "iLogic")
    Return
End Try

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

Dim oPlacePoint As Point2d

If Not oBorder Is Nothing Then
    ' A border exists. The placement point        
    ' is the top-right corner of the border. 
    oOffset = 12.77 'user defined offset
    oX = oBorder.RangeBox.MaxPoint.X
    oY = oBorder.RangeBox.MinPoint.Y + oOffset
    oPlacePoint = ThisApplication.TransientGeometry.CreatePoint2d(oX,oY)
Else
    ' There is no border 
     
    oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(20, 20)
     
     iLogicVb.UpdateWhenDone = True
End If

Dim oPartslist As PartsList

Try        
    'look for the first parts list found on the sheet 
    'if succesful finding it, 
    'tell the user,then Do Nothing
    oPartslist = oSheet.PartsLists(1)
    MessageBox.Show("There is an existing Parts List", "iLogic")
    
Catch
    ' Create the parts list.  
    oPartsList = oSheet.PartsLists.Add(oDrawingView, oPlacePoint)
End Try
End If
0 Likes
Message 3 of 5

bradeneuropeArthur
Mentor
Mentor
Accepted solution

Hi Measure first the location of the title-block and the inside dimension of the border.

for me the is 41.5 cm in X direction and 10 cm in Y direction.

use this as point values:

If iProperties.Value("Summary", "Category") = "X" Then 


iLogicVb.UpdateWhenDone = True   

' Set a reference to the drawing document.    ' This assumes a drawing document is active.    
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

'Set a reference to the active sheet.    
Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet    

' Set 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

Try
    oDrawingView = oSheet.DrawingViews(1)
Catch
    MessageBox.Show("No View found. Can not continue", "iLogic")
    Return 'return exits the rule
End Try

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

Dim oPlacementPoint As Point2d

If Not oBorder Is Nothing Then
    ' A border exists. The placement point        
    ' is the top-right corner of the border.        
    'oPlacementPoint = oBorder.RangeBox.MaxPoint
	oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(41.5, 10)  
Else
    ' There is no border      
    oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(41.5, 0.5)     
     
End If

Dim oPartslist As PartsList

Try        
    'look for the first parts list found on the sheet 
    'if succesful finding it, 
    'tell the user,then Do Nothing
    oPartslist = oSheet.PartsLists(1)
    MessageBox.Show("There is an existing Parts List", "iLogic")
    
Catch
    'if one is not found, Create it
    oPartslist = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint)
End Try
End If

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

Message 4 of 5

Anonymous
Not applicable

I want to  make the first statement apply to two different things "Assembly" and "Welding" 

Do I have to write it as 

SyntaxEditor Code Snippet

If iProperties.Value("Summary", "Category") = "ASSEMBLY" Then

and 

 SyntaxEditor Code Snippet

ELSE If iProperties.Value("Summary", "Category") = "Welding" Then

 

It works this way, but have to copy the code twice.  Is there a better way

0 Likes
Message 5 of 5

Anonymous
Not applicable

SyntaxEditor Code Snippet

If iProperties.Value("Summary", "Category") = "ASSEMBLY"  Or iProperties.Value("Summary", "Category") = "WELDING" Then
0 Likes