Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
dparmarF6BDE
in reply to: A.Acheson

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