Read Part List from an Assembly and create corresponding sheets for each part with base view and parts list sorted

Read Part List from an Assembly and create corresponding sheets for each part with base view and parts list sorted

G.Binl
Advocate Advocate
600 Views
5 Replies
Message 1 of 6

Read Part List from an Assembly and create corresponding sheets for each part with base view and parts list sorted

G.Binl
Advocate
Advocate

This is a larger order I'm sure I have a few pieces of the puzzle but would like to place them all into one rule or blocks of rules.

I have some rules that allow me to do items 3, 4, & 5 on an established drawing package.

I can do single sheet and multi sheets with Items 3,4 & 5 all of which are separate rules with a few nuances but work.

I would like to read this Parts List that’s on a cover sheet.

 

  1. Start a new Drawing or Sheet to this drawing that it read from.
  2. Navigate to file (101 – Supply from tank) and add a Base view with top, side view and isometric.
  3. Add Parts List for the Base view place at top of drawing.
  4. Sort Parts list.
  5. Add Rev Block at a certain location
  6. Add Third angle sketch that lives in our Sketch symbols as ( Projection – Third Angle )
  7. Next
  8.  

Folders and assemblies are consistent as seen in A and A1

Any Help would be great thanks all

GarrettBingle_4-1643668977869.png

GarrettBingle_6-1643669062357.png

 

GarrettBingle_2-1643668718192.pngGarrettBingle_3-1643668747795.png

 

 

 

0 Likes
601 Views
5 Replies
Replies (5)
Message 2 of 6

A.Acheson
Mentor
Mentor

This looks like a ilogic/vba automation request. So will need to be moved by the moderator to the programming forum. @johnsonshiue could you take care of this move when you have a chance? 

 

Can you supply the rules you are looking to integrate? This will help cut down on the amount of work required to help you and also see how you want this constructed. 

 

  1. Questions are the views to be added are they contained in a sheet set or to be on the fly generated views? 
  2. Is the model/folder reference in the part number actually linked to an assembly or is it just text?

Some links from the API help are below, they may help you get further. I would supply just work with a String file path so you can get the drawing creating functioning then integrate in the retrieval of the string later.

 

 

Parts list query

Add sheet set containing views 

Adding symbols

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

G.Binl
Advocate
Advocate

Thanks for the feed back.

I'm using this for adding parts list:

'Need to add a sorting function
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

Im useing this for sorting the parts list.

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oPartsList1 As PartsList
oPartsList1 = oDrawDoc.ActiveSheet.PartsLists.Item(1)
oPartsList1.Sort("ASME BPE", 0, "SIZE", 0, "QUANTITY", 0)

and this for the REV block placement:
Sub Main RemoveAllTags()
	Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument

	For Each oSheet In oDrawDoc.Sheets
		oSheet.activate
		ProcessSheet(oSheet)
	Next
	oDrawDoc.Update
End Sub


Sub ProcessSheet(oSheet As Sheet)

	If oSheet.RevisionTables.Count = 0 Then
		On Error Resume Next
	End If
	
	Dim oRTB As RevisionTable = oSheet.RevisionTables.Item(1)

	Dim oRows As RevisionTableRows = oRTB.RevisionTableRows
	oRows.Add()

	Dim oRow As RevisionTableRow = oRTB.RevisionTableRows.Item(oRTB.RevisionTableRows.Count)
	For Each oRow In oRows
		If oRow.IsActiveRow Then

		Else
			oRow.Delete
		End If
	Next
oRTB.Delete
oDrawDoc = ThisApplication.ActiveDocument
Dim oRTBs As RevisionTables
oRTBs = oDrawDoc.ActiveSheet.RevisionTables
			
Dim oLocation As Point2d
oLocation = ThisApplication.TransientGeometry.CreatePoint2d(68.08999997, 9.780835)

oRTB = oRTBs.Add(oLocation)

End Sub

hope this helps


 

0 Likes
Message 4 of 6

G.Binl
Advocate
Advocate

oops sorry i did not answer your questions 

1. Views would be fly generated, because there is always different scaling which would be done manually when the drawing gets detailed.

2. The Texted name is the model name as seen in A1.

GarrettBingle_0-1643720258838.png

 

0 Likes
Message 5 of 6

A.Acheson
Mentor
Mentor

If I was building this I would likely set it up with sub routines for each operation, it is easier to digest and also they are good for use in other projects also. You could start with the layout sub routine inside sub main where your bullet points can serve as the action plan to launch each stage. If there is common objects between all of the sub routines then declare and set them in Sub Main then pass them to each sub routine that needs them. This leads to easier controlled objects. Even if you establish a calling sub routine and in  the sub routine is a message box then that would be a good starting point. 

 

Sub Main

Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument

 

  1. Start a new Drawing or Sheet to this drawing that it read from.
  2. Navigate to file (101 – Supply from tank) and add a Base view with top, side view and isometric.
  3. Add Parts List for the Base view place at top of drawing.
  4. Sort Parts list.
  5. Add Rev Block at a certain location              
  6. Add Third angle sketch that lives in our Sketch symbols as ( Projection – Third Angle )

End Sub

 

Here is a link to adding a Base view to a sheet. Once you have that in then you can start trying to position each view and add additional views. Sheet sets is easier as all the views are layed out in advance. 

 

If you have more specific question please ask away. 

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

G.Binl
Advocate
Advocate

@A.Acheson 

Thanks for the Advice I was thinking the same thing keeping separate Rules and step through

a sequence of events. 

0 Likes