I have several iparts that are doors or drawer fronts. There is a desire to have 1 print for every door or front. For every ipart factory there are between 35 and 100 parts. I have been working on a macro that will swap each door and auto create a pdf and an idw for every door within the factory. The problem I'm running into is that I have a detail view from a door that I do not want to swap. I iterate through all the views, and I only want to raplace the views with specific names, in this case the front, back, and iso.
So lets say I'm using door -06 for a close up detail view. The code starts, itterates through doors -01 through -06, and swaps out everything fine. However, at -07 it swaps out my detail view for the -07 door and contiinues swaping it until I hit all 90+ doors.
Below is an excerpt from my module and you can see I'm using ReplaceReference to swap out the door.
'iterate through the rows Dim oRow As iPartTableRow For Each oRow In oFactory.TableRows 'make this the active row so the model will recompute. oFactory.DefaultRow = oRow 'get the name of the ipart oMemberFile = oRow.PartName oMemberName = oRow.MemberName oMemberWidth = oParentPartDoc.ComponentDefinition.Parameters.Item("width").Value * 10 ' select parametr by name oMemberLength = oParentPartDoc.ComponentDefinition.Parameters.Item("length").Value * 10 ' select parametr by name oMemberThick = oParentPartDoc.ComponentDefinition.Parameters.Item("thickness").Value * 10 ' select parametr by name oMemberTemplate = oRow.Item(iTemplateColumnIndex).Value 'oParentPartDoc.ComponentDefinition.Parameters.Item("template").Value ' select parametr by name ScaleH = (WindowH - 2 * ViewSpacing) / (oMemberWidth + oMemberLength + oMemberThick) ScaleV = (WindowV - ViewSpacing) / (oMemberLength + oMemberThick) If Len(Dir(templatesfileLocation & oMemberTemplate & ".idw")) > 0 Then 'get the drawing template Set oDrawingDoc = ThisApplication.Documents.Open(templatesfileLocation & oMemberTemplate & ".idw") Set oSheet = oDrawingDoc.ActiveSheet 'get the drawing view Dim oView As DrawingView For Each oView In oSheet.DrawingViews Select Case oView.Name Case "FRONT", "BACK", "ISO" Call oView.ReferencedDocumentDescriptor.ReferencedFileDescriptor.ReplaceReference(ipartsfileLocation & oMemberFile) If ScaleH > ScaleV Then oView.[Scale] = ScaleV Else oView.[Scale] = ScaleH End If Case Else End Select Next Call oDrawingDoc.Update2(True) 'save copy as one new idw using the member name in the prints folder Call oDrawingDoc.SaveAs(printsfileLocation & oMemberName & ".idw", True) Call oDrawingDoc.SaveAs(printsfileLocation & oMemberName & ".pdf", True) End If Next