Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
My current code cycles through each row on the parts list table,
I just need to get the file location of that part/assembly such as row(1) = "C:\Temp\part.ipt" to place a view of that part on the opened sheet.
' CODE BELOW ==============
# NEW IMPLEMENTATION CODE =============
oDoc = ThisApplication.Documents.Open("",False)
oPoint1 = ThisApplication.TransientGeometry.CreatePoint2d(11, 11)
Dim ViewScale As Double = 0.1
Dim oDrawingDoc As DrawingDocument = ThisDoc.Document
Dim oSheet As Sheet = oDrawingDoc.ActiveSheet
oSheet.DrawingViews.AddBaseView(oDoc,oPoint1, ViewScale,kFrontViewOrientation, DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle)
# OLD =============
Sub CreatingDrawings
If Create_Drawings_From_BOM = True
oDocDef1 = ThisDoc.Document
Dim oSheet1 As Sheet = oDocDef1.ActiveSheet
lPos1 = InStr(oSheet1.Name, ":")
sLen1 = Len(oSheet1.Name)
sSheetNamesOrignal = Left(oSheet1.Name, lPos1 - 1)
Dim sSheetNumber As Integer = Right(oSheet1.Name, sLen1 -lPos1)
Dim oDoc As DrawingDocument = ThisDoc.Document
Dim oPartslist As PartsList = oDoc.Sheets.Item(sSheetNumber).PartsLists(1)
Dim PartsListArray As New ArrayList
For Each oRow As PartsListRow In oPartslist.PartsListRows
======== > FOR EACH ROW RETURN IT'S FILE LOCATION < ========
Dim oItemDrawingNumber As String = oRow.Item("DRAWING NUMBER").Value
If oItemDrawingNumber <>"" Then
PartsListArray.Add(oItemDrawingNumber)
End If
Next
AllSheetsTemp = ThisDrawing.Document.Sheets
Dim SheetListArray As New ArrayList
For Each oSheetDwg As Sheet In AllSheetsTemp
lPos = InStr(oSheetDwg.Name, ":")
sLen = Len(oSheetDwg.Name)
sSheetNames = Left(oSheetDwg.Name, lPos - 1)
SheetListArray.Add(sSheetNames)
Next
For i = PartsListArray.Count - 1 To 0 Step -1
DrawingNumberCheck = PartsListArray.Item(i)
For x = SheetListArray.Count - 1 To 0 Step -1
SheetListNumberCheck = SheetListArray.Item(x)
If SheetListNumberCheck = DrawingNumberCheck
PartsListArray.Remove(SheetListNumberCheck)
End If
Next
Next
For i = PartsListArray.Count - 1 To 0 Step -1
Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oFormat As SheetFormat = oDrawDoc.SheetFormats.Item("A3 size, 2 views")
'Try
Dim oModel As Document = ThisApplication.Documents.Open("C:\temp\TempFile.ipt", False)
Dim oSheet2 As Sheet = oDrawDoc.Sheets.AddUsingSheetFormat(oFormat, oModel)
Dim oDoc1 As DrawingDocument = ThisDoc.Document
Dim oSheet As Sheet = oDoc1.ActiveSheet
Dim oView As DrawingView
For Each oView In oSheet.DrawingViews
oView.Delete
Next
'Catch
ThisDoc.Document.ActiveSheet.Name = PartsListArray(i)
Dim oDoc2 As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet3 As Sheet = oDoc2.ActiveSheet
Dim oPromptEntry
oTitleBlock=oSheet3.TitleBlock
oTextBoxes=oTitleBlock.Definition.Sketch.TextBoxes
For Each oTextBox In oTitleBlock.Definition.Sketch.TextBoxes
Select oTextBox.Text
Case "<USED_ON>"
oPromptEntry = sSheetNamesOrignal
Call oTitleBlock.SetPromptResultText(oTextBox, oPromptEntry)
End Select
Next
'End Try
Next
Create_Drawings_From_BOM = False
End If
End Sub
Solved! Go to Solution.