Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Automated Drawings for parts, views update and export as pdf

dparmarF6BDE
Enthusiast

Automated Drawings for parts, views update and export as pdf

dparmarF6BDE
Enthusiast
Enthusiast

Hello All,
I am trying to create automated finished good drawing in bulk using Ilogic. I am using inventor 2024. The goal here is to update a part which is an ipart factory part and based on the new updated part, all the other parts inn the drawing i want to update and after the update, I want to export that drawing as a pdf file and move on to the next part.
As per the image, lets assume that the part "DUMMY_1" has a part name as it is a master part of the ipart factory and the current member name is "10-28", based on the 10-28 i want to update the part "DUMMY_2" to update to a member where it matches with my requirements and as same as the previous situation, I want to update the part"DUMMY_3" based on the certain characters in the Part name of  the "DUMMY_1" part. after updating the members in all three views. We can save the file at given location as a PDF. Things to keep in mind, all three are an ipart factory parts, I have the parts made as a child parts for all three of them as well, whatever works and easy on the system so it wont crash. Thanks in advance! Happy manufacturing!
@A.Acheson 

dparmarF6BDE_0-1706554908172.png

 

0 Likes
Reply
583 Views
6 Replies
Replies (6)

A.Acheson
Mentor
Mentor

Hi @dparmarF6BDE 

 

What your suggesting is more than likely possible. There is a lot of work to go into R&D your workflow so I am assuming your post is more for advice. I would suggest to break it down into bite size lists following closely your manual workflow. Once you have a list operations starting looking for suitable blocks of code to automate those tasks. I would suggest using all external rules. If you have been at this a while you likely have something you can reuse.

 

I am not certain what type of automation you want on the drawing but here is one workflow you undertook awhile back

 

If you want help with any specific aspect please post the code your using along with a description of what you want to do next and what the code is doing currently.

 

Happy Automating....

 

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

dparmarF6BDE
Enthusiast
Enthusiast

hello @A.Acheson ,
here is the derived script i have been using so far. now about the work flow, I have thought about an approach which seems pretty straight forward but want to test the feasibility (coding wise). So I have and excel in the same directory as the current Idw file for example. now there is only one sheet in that workbook and as per the image shown below, I have three column, now from the ilogic, I want to open the excel and start a "for loop" from 2nd row till the row 2500 for example. Now looping through each row, I want to change the "DUMMY 1" Ipart member to the column A cell value, similarly I want to do the same for the other two views and their Ipart. So every time we jump to a new row, all the three views is gonna get updated to the member name in row. Can we achieve this using Ilogic? Thanks in Advance!

dparmarF6BDE_1-1708436782613.pngdparmarF6BDE_2-1708436946698.png

 

Sub Main

	Dim oDrawing As DrawingDocument = ThisApplication.ActiveDocument
	Dim oPath As String = "C:\IMAGINE" 'Folder to save the drawings
	Dim oFactory As iPartFactory
	
	
	
	For Each oView As DrawingView In oDrawing.ActiveSheet.DrawingViews
		Dim oDoc As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
		oFactory = oDoc.ComponentDefinition.ipartMember.ParentFactory
		Exit For
	Next
	
	Dim memberName As String = InputBox("Enter the Membername you wish to Start the Loop", "iLogic", "CBCAL0820PL01") 
	
	If oFactory Is Nothing = False Then
		For Each oRow As iPartTableRow In oFactory.TableRows
				If Not oRow.MemberName = memberName AndAlso  Not memberName Is Nothing Then Continue For
				memberName = Nothing
			
			For Each oView In oDrawing.ActiveSheet.DrawingViews
				If oView.ActiveMemberName <> oRow.MemberName Then oView.ActiveMemberName = oRow.MemberName
				oDrawing.Update
				
' Get the DXF translator Add-In.
Dim DXFAddIn As TranslatorAddIn
DXFAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC4-122E-11D5-8E91-0010B541CD80}")
'Set a reference to the active document (the document to be published).
Dim oDocument As Document
oDocument = ThisApplication.ActiveDocument
Dim oContext As TranslationContext
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
' Create a NameValueMap object
Dim oOptions As NameValueMap
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
' Create a DataMedium object
Dim oDataMedium As DataMedium
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
' Check whether the translator has 'SaveCopyAs' options
If DXFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then
Dim strIniFile As String
strIniFile = "C:\temp\dxfout.ini"
' Create the name-value that specifies the ini file to use.
oOptions.Value("Export_Acad_IniFile") = strIniFile
End If
'Set the destination file name
Dim dxfFileName As String = oPath & "\DXF\" & oRow.MemberName & ".dxf"
oDataMedium.FileName = dxfFileName


iLogicVb.RunRule("FIXED SCALE")
iLogicVb.RunRule("POSITION")

'Publish document.
oDrawing.Update
DXFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)	

				Do While oView.IsUpdateComplete = False
					Call ThisApplication.UserInterfaceManager.DoEvents
				Loop
			Next
			
			'oDrawing.SaveAs(oPath & "\" & oRow.MemberName & ".idw", True)
			'oDrawing.SaveAs(oPath & "\PDF\" & oRow.MemberName & ".pdf", True)
		Next
	End If
End Sub

 

 

 

 

 

0 Likes

A.Acheson
Mentor
Mentor

I wouldn't see an issue doing that. Your just looking up the excel value and changing each member on each view to match. Have you looked at go excel examples on this forum? First thing you needed to do is to read the excel sheet and bring back the correct value.

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

dparmarF6BDE
Enthusiast
Enthusiast

Hello @A.Acheson ,

in this script, how would  we identify more than one view in our script if they are in the drawing. I have three views and their names are view1, view2 and view3. I want to update these all view at every stage of the loop since they all have different ipart factory parts. I got the script for excel and here it is, I am still trying to construct the code, so it will follow this workflow.

1. go to row 1 in excel

2. update the view1 ipart partmember to Cell A1

3. update the view2 ipart partmember to Cell B1

4. update the view3 ipart partmember to Cell C1

5. update the drawing and arrange the dimensions on those views.

6. save it as a pdf and the name of the file is in the excel so cell D1 value has to match with the file name for that loop.

7. jump to the next row

 

here i want to assign the cell values to the different views and their active partmember, if you can help me out a bit here! I would really appreciate this. thanks in advance. The first script is the one that i modified a bit and the second script is the one that you gave me as a solution of my questions before.

owbook = "C:"
owSheet = "MASTER"
GoExcel.Open(owbook,owSheet)

'start row to use
Dim oStartRow As Integer
oStartRow = 1

'number of rows to use
Dim oRowlastcount As Long
oRowlastcount = 25

'--------------------------------------------------------------------------------------------------------------------------------'
Dim oCrossSecdoc As DrawingDocument = ThisApplication.ActiveDocument
oCrossSecdoc = ThisApplication.ActiveDocument

Dim oFactory As iPartFactory
Dim oView1Member As String
Dim oView2Member As String
Dim oView3Member As String

'--------------------------------------------------------------------------------------------------------------------------------'




Dim i As Integer
For i = oStartRow To oRowlastcount
  Dim strx As String, stry As String
  strx = GoExcel.CellValue(owbook,owSheet, "A" & i)
  stry = GoExcel.CellValue(owbook,owSheet, "B" & i)    

Next

 

Sub Main

	Dim oDrawing As DrawingDocument = ThisApplication.ActiveDocument
	Dim oPath As String = "C:\" 'Folder to save the drawings
	Dim oFactory As iPartFactory
	
	
	
	For Each oView As DrawingView In oDrawing.ActiveSheet.DrawingViews
		Dim oDoc As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
		oFactory = oDoc.ComponentDefinition.ipartMember.ParentFactory
		Exit For
	Next
	
	Dim memberName As String = InputBox("Enter the Membername you wish to Start the Loop", "iLogic", "abcd") 
	
	If oFactory Is Nothing = False Then
		For Each oRow As iPartTableRow In oFactory.TableRows
				If Not oRow.MemberName = memberName AndAlso  Not memberName Is Nothing Then Continue For
				memberName = Nothing
			
			For Each oView In oDrawing.ActiveSheet.DrawingViews
				If oView.ActiveMemberName <> oRow.MemberName Then oView.ActiveMemberName = oRow.MemberName
				oDrawing.Update
				
' Get the DXF translator Add-In.
Dim DXFAddIn As TranslatorAddIn
DXFAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC4-122E-11D5-8E91-0010B541CD80}")
'Set a reference to the active document (the document to be published).
Dim oDocument As Document
oDocument = ThisApplication.ActiveDocument
Dim oContext As TranslationContext
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
' Create a NameValueMap object
Dim oOptions As NameValueMap
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
' Create a DataMedium object
Dim oDataMedium As DataMedium
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
' Check whether the translator has 'SaveCopyAs' options
If DXFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then
Dim strIniFile As String
strIniFile = "C:\temp\dxfout.ini"
' Create the name-value that specifies the ini file to use.
oOptions.Value("Export_Acad_IniFile") = strIniFile
End If
'Set the destination file name
Dim dxfFileName As String = oPath & "\DXF\" & oRow.MemberName & ".dxf"
oDataMedium.FileName = dxfFileName


iLogicVb.RunRule("FIXED SCALE")
iLogicVb.RunRule("POSITION")

'Publish document.
oDrawing.Update
DXFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)	

				Do While oView.IsUpdateComplete = False
					Call ThisApplication.UserInterfaceManager.DoEvents
				Loop
			Next
			
			'oDrawing.SaveAs(oPath & "\" & oRow.MemberName & ".idw", True)
			'oDrawing.SaveAs(oPath & "\PDF\" & oRow.MemberName & ".pdf", True)
		Next
	End If
End Sub
0 Likes

A.Acheson
Mentor
Mentor

t to separate the views you would do so in the For Loop of Drawing Views. 

 

You can either call a sub routine and offer the view as an argument or you can filter the view object within the loop but in this case all of the routine needs to be within this loop. A sub routine might be a cleaner approach. 

 

See example here, it isn't finished but you should get the structure.

Sub Main
    Dim oDrawing As DrawingDocument = ThisApplication.ActiveDocument
    For Each oView As DrawingView In oDrawing.ActiveSheet.DrawingViews
		
		If oView.Name = "view1" Then
			'update the view1 ipart partmember to Cell A1, pass the excelvalue for partmember into the sub routine as argument
			partMember = 1
			ProcessView(drawView,partMember)
		ElseIf View.Name = "view2" Then
			'update the view1 ipart partmember to Cell B1, pass the excelvalue for partmember into the sub routine as argument
			partMember = 2
			ProcessView(drawView,partMember)
		ElseIf View.Name = "view3" Then
			'update the view1 ipart partmember to Cell C1, pass the excelvalue for partmember into the sub routine as argument
			partMember = 3
			ProcessView(drawView,partMember)
		End IF

    Next

End Sub

Sub ProcessView(drawView As DrawingView,partMember As String)

	'Do something with the view object
	MessageBox.Show(partMember, "partMember")
	MessageBox.Show(drawView.Name,"Drawing View Name")

End Sub

 

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

dparmarF6BDE
Enthusiast
Enthusiast

Hello @A.Acheson ,
I am trying an approach, derived from the previous script and cant make it working. instead of trying to loop through each view, is it possible to define separate view variable in advance from the labels of the view, so as soon as we jump on the next row, we can change the partmember by excel values. If you think it is not a right approach, please provide the previous code with at least one view example, as I am struggling with the structure. the biggest challenge is to define the view then define the partfactroy for the member that is in that view. thanks again!

Sub Main


    Dim oCrossSecdoc As DrawingDocument = ThisApplication.ActiveDocument
	
	Dim oPathpdf As String = "C:\" 'Folder to save the drawings
	Dim oFactory As iPartFactory
	
	owbook = "C:"
	owSheet = "MASTER"
	GoExcel.Open(owbook,owSheet)
	
	Dim oView1Member As String
	Dim oView2Member As String
	Dim oView3Member As String
	Dim currentfilename As String

	Dim oView1 As DrawingView
    oView1 = oCrossSecdoc.ActiveSheet.DrawingViews(1)
	Dim oView2 As DrawingView
    oView1 = oCrossSecdoc.ActiveSheet.DrawingViews(2)
	Dim oView3 As DrawingView
    oView1 = oCrossSecdoc.ActiveSheet.DrawingViews(3)
	
	Dim oPartDoc1 As PartDocument
	oPartDoc1 = oView1.ReferencedDocumentDescriptor.ReferencedDocument
'	Dim oPartDoc2 As PartDocument
'	oPartDoc2 = oView2.ReferencedDocumentDescriptor.ReferencedDocument
'	Dim oPartDoc3 As PartDocument
'	oPartDoc3 = oView3.ReferencedDocumentDescriptor.ReferencedDocument
	
	Dim oDef1 As PartComponentDefinition
	oDef1 = oPartDoc1.ComponentDefinition
	Dim oDef2 As PartComponentDefinition
'	oDef2 = oPartDoc2.ComponentDefinition
	Dim oDef3 As PartComponentDefinition
'	oDef3 = oPartDoc3.ComponentDefinition
	
	
	Dim iPart1 As iPartFactory
	Dim iPart2 As iPartFactory
	Dim iPart3 As iPartFactory

	Dim oRow1 As iPartTableRow
	Dim oRow2 As iPartTableRow
	Dim oRow3 As iPartTableRow
	
	iPart1 = oDef1.iPartMember.ParentFactory
'	iPart2 = oDef2.iPartMember.ParentFactory
'	iPart3 = oDef3.iPartMember.ParentFactory
			
	Dim i As Integer
	
	'start row to use
	Dim oStartRow As Integer
	oStartRow = 2
	
	'number of rows to use
	Dim oRowlastcount As Long
	oRowlastcount = 5
	

		For i = oStartRow To oRowlastcount
			
			  oView1Member = GoExcel.CellValue(owbook, owSheet, "A" & i)
			  oView2Member = GoExcel.CellValue(owbook, owSheet, "B" & i)
			  oView3Member = GoExcel.CellValue(owbook, owSheet, "C" & i)
			  currentfilename = GoExcel.CellValue(owbook, owSheet, "D" & i)
			  
			  MessageBox.Show(oView1Member, "partMember")
'			  MessageBox.Show(oView2Member, "partMember")
'			  MessageBox.Show(oView3Member, "partMember")
'			  MessageBox.Show(currentfilename, "Filename")
			  oView1.ActiveMemberName = oView1Member 
			  oCrossSecdoc.SaveAs(oPathpdf & "\" & currentfilename & ".pdf", True)

    	Next

End Sub

'Sub ProcessView(drawView As DrawingView,partMember As String)

'	Do something With the view Object
'	MessageBox.Show(partMember, "partMember")
'	MessageBox.Show(drawView.Name,"Drawing View Name")

'End Sub
0 Likes