Drawing creation for each Part

Drawing creation for each Part

richie_tony007
Participant Participant
303 Views
5 Replies
Message 1 of 6

Drawing creation for each Part

richie_tony007
Participant
Participant

Hi All,

 

I want to create two views for each part in this code but i dont know how to use document as a component occurences

 

Sub main

	Dim modelReference As Document = ThisApplication.ActiveDocument

	CreateSheet()
	
	ShowPanelParts(modelReference)





End Sub

Sub CreateSheet
	' Set the path to the template file
	Dim templatePath As String = "C:\_VaultPro\Templates\MKT DESIGN TEMPLATE.dwg"

	Dim oDoc As DrawingDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, templatePath)

	Dim oSheet As Sheet = oDoc.Sheets(1)


	' Display message
	MessageBox.Show("Drawing created successfully from the template!")
End Sub

Sub ShowPanelParts(modelReference As Document)

    ' Check if the document is an assembly
    If modelReference.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
        ' Get the assembly document
        Dim oAsmDoc As AssemblyDocument = modelReference

        ' Create a collection to store unique part names (without "LEFT" or "RIGHT")
        Dim uniqueParts As New Collection()

        ' Loop through all the components in the assembly
        For Each oComp As ComponentOccurrence In oAsmDoc.ComponentDefinition.Occurrences
            ' Skip suppressed parts
            If oComp.Suppressed = False Then
                ' Check if the component name contains "PANEL" (case-sensitive, all uppercase)
                If InStr(oComp.Name, "PANEL") > 0 Then
                    ' Remove "LEFT" and "RIGHT" from the name to treat them as one part
                    Dim partName As String = oComp.Name.ToUpper()

                    ' Remove "LEFT" or "RIGHT" from the name
                    partName = Replace(partName, " LEFT", "")
                    partName = Replace(partName, " RIGHT", "")

                    ' Check if the part name already exists in the unique parts collection
                    Dim isDuplicate As Boolean = False
                    For Each uniquePart As String In uniqueParts
                        If uniquePart = partName Then
                            isDuplicate = True
                            Exit For
                        End If
                    Next

                    ' If it's not a duplicate, add it to the collection and show the message
                    If Not isDuplicate Then
                        uniqueParts.Add(partName)
'						CreateViews(oComp)
                        MessageBox.Show("Found part: " & oComp.Name)
						CreateViews(oComp)
                    End If
                End If
            End If
        Next
    Else
        MessageBox.Show("The active document is not an assembly.")
    End If
End Sub




'*** Define Scale
Sub CreateViews(oComp As ComponentOccurrence)
	' Scale for the views
    Dim scale As Double = 1 / 3

    ' Get Active Drawing Sheet
    Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
    Dim oSheet As Sheet = oDoc.ActiveSheet
    DeleteAllViews(oSheet)

    ' Define View Locations
    Dim sheetCenterVertical As Double = (oSheet.Height / 2)
    Dim isoViewHorizontal As Double = (oSheet.Width * 0.25)
    Dim frontViewHorizontal As Double = (oSheet.Width * 0.75)

    ' Create Points for View Locations
    Dim oIsoViewPoint As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(isoViewHorizontal, sheetCenterVertical)
    Dim oFrontViewPoint As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(frontViewHorizontal, sheetCenterVertical)

    ' Define View Orientation
    Dim isoViewOrientation As ViewOrientationTypeEnum = kIsoTopRightViewOrientation
    Dim frontViewOrientation As ViewOrientationTypeEnum = kFrontViewOrientation

    ' Define View Style
    Dim isoViewStyle As DrawingViewStyleEnum = kShadedDrawingViewStyle
    Dim frontViewStyle As DrawingViewStyleEnum = kHiddenLineRemovedDrawingViewStyle

    ' Create the Views for the specific panel part
    Dim oIsoView As DrawingView = oSheet.DrawingViews.AddBaseView(oComp, oIsoViewPoint, scale, isoViewOrientation, isoViewStyle)
    oIsoView.Name = oComp.Name & " ISOMETRIC VIEW"

    Dim oFrontView As DrawingView = oSheet.DrawingViews.AddBaseView(oComp, oFrontViewPoint, scale, frontViewOrientation, frontViewStyle)
    oFrontView.Name = oComp.Name & " FRONT VIEW"

End Sub

'*** Function To Delete All Views
Sub DeleteAllViews(oSheet As Sheet)
	Dim oView As DrawingView
	For Each oView In oSheet.DrawingViews
		oView.Delete()
	Next
End Sub

 

Can any one help please

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

Ivan_Sinicyn
Advocate
Advocate

Hi,

Try this^

Sub Main
    ' Get the active document (must be an assembly)
    Dim modelReference As Document = ThisApplication.ActiveDocument
    
    ' Check if the active document is an assembly
    If modelReference.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
        MessageBox.Show("The active document must be an assembly.")
        Exit Sub
    End If
    
    ' Create a new drawing
    Dim oDrawingDoc As DrawingDocument = CreateSheet()
    
    ' Check if the drawing was created successfully
    If oDrawingDoc Is Nothing Then
        MessageBox.Show("Failed to create the drawing. Rule execution aborted.")
        Exit Sub
    End If
    
    ' Pass the model and drawing to create views
    ShowPanelParts(modelReference, oDrawingDoc)
End Sub

Function CreateSheet() As DrawingDocument
    ' Specify the path to the template file
    Dim templatePath As String = "C:\_VaultPro\Templates\MKT DESIGN TEMPLATE.dwg"
    
    ' Check if the template file exists
    If Not System.IO.File.Exists(templatePath) Then
        MessageBox.Show("Error: Template file '" & templatePath & "' not found. Ensure the path is correct and the file is accessible.")
        Return Nothing
    End If
    
    ' Try to create a new drawing based on the template
    Try
        Dim oDoc As DrawingDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, templatePath)
        
        ' Activate the first sheet
        Dim oSheet As Sheet = oDoc.Sheets.Item(1)
        
        ' Notify about successful drawing creation
        MessageBox.Show("Drawing successfully created from the template!")
        
        ' Return the created drawing
        Return oDoc
    Catch ex As Exception
        MessageBox.Show("Error creating drawing: " & ex.Message)
        Return Nothing
    End Try
End Function

Sub ShowPanelParts(modelReference As Document, oDrawingDoc As DrawingDocument)
    ' Check if the document is an assembly
    If modelReference.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
        Dim oAsmDoc As AssemblyDocument = modelReference
        
        ' Get the active sheet of the drawing
        Dim oSheet As Sheet = oDrawingDoc.ActiveSheet
        
        ' Create a collection for unique part names
        Dim uniqueParts As New Collection
        
        ' Loop through all components in the assembly
        For Each oComp As ComponentOccurrence In oAsmDoc.ComponentDefinition.Occurrences
            If oComp.Suppressed = False Then
                ' Check if the component name contains "PANEL"
                If InStr(oComp.Name, "PANEL") > 0 Then
                    Dim partName As String = oComp.Name.ToUpper()
                    partName = Replace(partName, " LEFT", "")
                    partName = Replace(partName, " RIGHT", "")
                    
                    ' Check if the part is already in the collection
                    Dim isDuplicate As Boolean = False
                    For Each uniquePart As String In uniqueParts
                        If uniquePart = partName Then
                            isDuplicate = True
                            Exit For
                        End If
                    Next
                    
                    ' If the part is unique, add it and create views
                    If Not isDuplicate Then
                        uniqueParts.Add(partName)
                        CreateViews(oComp, oSheet)
                        MessageBox.Show("Found part: " & oComp.Name)
                    End If
                End If
            End If
        Next
    Else
        MessageBox.Show("The provided document is not an assembly.")
    End If
End Sub

Sub CreateViews(oComp As ComponentOccurrence, oSheet As Sheet)
    ' Set the scale for the views
    Dim scale As Double = 1 / 3
    
    ' Define the view locations on the sheet
    Dim sheetCenterVertical As Double = (oSheet.Height / 2)
    Dim isoViewHorizontal As Double = (oSheet.Width * 0.25)
    Dim frontViewHorizontal As Double = (oSheet.Width * 0.75)
    
    ' Create points for view placement
    Dim oIsoViewPoint As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(isoViewHorizontal, sheetCenterVertical)
    Dim oFrontViewPoint As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(frontViewHorizontal, sheetCenterVertical)
    
    ' Define view orientations
    Dim isoViewOrientation As ViewOrientationTypeEnum = kIsoTopRightViewOrientation
    Dim frontViewOrientation As ViewOrientationTypeEnum = kFrontViewOrientation
    
    ' Define view styles
    Dim isoViewStyle As DrawingViewStyleEnum = kShadedDrawingViewStyle
    Dim frontViewStyle As DrawingViewStyleEnum = kHiddenLineRemovedDrawingViewStyle
    
    ' Create views for the component
    Try
        Dim oIsoView As DrawingView = oSheet.DrawingViews.AddBaseView(oComp.Definition.Document, oIsoViewPoint, scale, isoViewOrientation, isoViewStyle)
        oIsoView.Name = oComp.Name & " ISOMETRIC VIEW"
        
        Dim oFrontView As DrawingView = oSheet.DrawingViews.AddBaseView(oComp.Definition.Document, oFrontViewPoint, scale, frontViewOrientation, frontViewStyle)
        oFrontView.Name = oComp.Name & " FRONT VIEW"
    Catch ex As Exception
        MessageBox.Show("Error creating views for part '" & oComp.Name & "': " & ex.Message)
    End Try
End Sub

 

If you want to create views for each part on a separate sheet, you will need to add the creation of a new sheet within the loop in ShowPanelParts using oDrawingDoc.Sheets.Add() and pass the new sheet to CreateViews.
INV 2025.3
0 Likes
Message 3 of 6

richie_tony007
Participant
Participant

Thanks for your reply. @Ivan_Sinicyn 

 

It works but the newly created sheet doesnt have a title block and the sheet sizes are different from the 1st sheet.i want the same title block and sheet sizes which i used for sheet 1

0 Likes
Message 4 of 6

Ivan_Sinicyn
Advocate
Advocate

You can use the first drawing sheet as a template and delete it at the end of the operation.

Sub Main
    ' Get the active document (must be an assembly)
    Dim modelReference As Document = ThisApplication.ActiveDocument
    
    ' Check if the active document is an assembly
    If modelReference.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
        MessageBox.Show("The active document must be an assembly.")
        Exit Sub
    End If
    
    ' Create a new drawing
    Dim oDrawingDoc As DrawingDocument = CreateSheet()
    
    ' Check if the drawing was created successfully
    If oDrawingDoc Is Nothing Then
        MessageBox.Show("Failed to create the drawing. Rule execution aborted.")
        Exit Sub
    End If
    
    ' Pass the model and drawing to create views
    ShowPanelParts(modelReference, oDrawingDoc)
End Sub

Function CreateSheet() As DrawingDocument
    ' Specify the path to the template file
    Dim templatePath As String = "C:\_VaultPro\Templates\MKT DESIGN TEMPLATE.dwg"
    
    ' Check if the template file exists
    If Not System.IO.File.Exists(templatePath) Then
        MessageBox.Show("Error: Template file '" & templatePath & "' not found. Ensure the path is correct and the file is accessible.")
        Return Nothing
    End If
    
    ' Try to create a new drawing based on the template
    Try
        Dim oDoc As DrawingDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, templatePath)
        
        ' Notify about successful drawing creation
        MessageBox.Show("Drawing successfully created from the template!")
        
        ' Return the created drawing
        Return oDoc
    Catch ex As Exception
        MessageBox.Show("Error creating drawing: " & ex.Message)
        Return Nothing
    End Try
End Function

Sub ShowPanelParts(modelReference As Document, oDrawingDoc As DrawingDocument)
    ' Check if the document is an assembly
    If modelReference.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
        Dim oAsmDoc As AssemblyDocument = modelReference
        
        ' Get the first sheet from the template to use as a base
        Dim oBaseSheet As Sheet = oDrawingDoc.Sheets.Item(1)
        
        ' Create a collection for unique part names
        Dim uniqueParts As New Collection
        
        ' Counter for sheet naming
        Dim sheetCounter As Integer = 1
        
        ' Loop through all components in the assembly
        For Each oComp As ComponentOccurrence In oAsmDoc.ComponentDefinition.Occurrences
            If oComp.Suppressed = False Then
                ' Check if the component name contains "PANEL"
                If InStr(oComp.Name, "PANEL") > 0 Then
                    Dim partName As String = oComp.Name.ToUpper()
                    partName = Replace(partName, " LEFT", "")
                    partName = Replace(partName, " RIGHT", "")
                    
                    ' Check if the part is already in the collection
                    Dim isDuplicate As Boolean = False
                    For Each uniquePart As String In uniqueParts
                        If uniquePart = partName Then
                            isDuplicate = True
                            Exit For
                        End If
                    Next
                    
                    ' If the part is unique, add it and create views on a copied sheet
                    If Not isDuplicate Then
                        uniqueParts.Add(partName)
                        
                        ' Copy the base sheet
                        Dim oNewSheet As Sheet = oBaseSheet.CopyTo(oDrawingDoc)
                        oNewSheet.Name = "Sheet " & sheetCounter & " - " & oComp.Name
                        sheetCounter = sheetCounter + 1
                        
                        ' Create views on the copied sheet
                        CreateViews(oComp, oNewSheet)
                        MessageBox.Show("Found part: " & oComp.Name & " - Views created on " & oNewSheet.Name)
                    End If
                End If
            End If
        Next
        
        ' Delete the original first sheet after all operations
        If oDrawingDoc.Sheets.Count > 1 Then
            oBaseSheet.Delete()
            ' Activate the first remaining sheet
            oDrawingDoc.Sheets.Item(1).Activate()
        End If
    Else
        MessageBox.Show("The provided document is not an assembly.")
    End If
End Sub

Sub CreateViews(oComp As ComponentOccurrence, oSheet As Sheet)
    ' Set the scale for the views
    Dim scale As Double = 1 / 3
    
    ' Define the view locations on the sheet
    Dim sheetCenterVertical As Double = (oSheet.Height / 2)
    Dim isoViewHorizontal As Double = (oSheet.Width * 0.25)
    Dim frontViewHorizontal As Double = (oSheet.Width * 0.75)
    
    ' Create points for view placement
    Dim oIsoViewPoint As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(isoViewHorizontal, sheetCenterVertical)
    Dim oFrontViewPoint As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(frontViewHorizontal, sheetCenterVertical)
    
    ' Define view orientations
    Dim isoViewOrientation As ViewOrientationTypeEnum = kIsoTopRightViewOrientation
    Dim frontViewOrientation As ViewOrientationTypeEnum = kFrontViewOrientation
    
    ' Define view styles
    Dim isoViewStyle As DrawingViewStyleEnum = kShadedDrawingViewStyle
    Dim frontViewStyle As DrawingViewStyleEnum = kHiddenLineRemovedDrawingViewStyle
    
    ' Create views for the component
    Try
        Dim oIsoView As DrawingView = oSheet.DrawingViews.AddBaseView(oComp.Definition.Document, oIsoViewPoint, scale, isoViewOrientation, isoViewStyle)
        oIsoView.Name = oComp.Name & " ISOMETRIC VIEW"
        
        Dim oFrontView As DrawingView = oSheet.DrawingViews.AddBaseView(oComp.Definition.Document, oFrontViewPoint, scale, frontViewOrientation, frontViewStyle)
        oFrontView.Name = oComp.Name & " FRONT VIEW"
    Catch ex As Exception
        MessageBox.Show("Error creating views for part '" & oComp.Name & "': " & ex.Message)
    End Try
End Sub
INV 2025.3
Message 5 of 6

BM_Ashraf
Advocate
Advocate

If you need a ready to use Add-in without complex Coding, check ADC (Automatic Drawing Creator)
https://bluemech.de/product/inventor-adc-automatic-drawing-creator/

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.

Blue Mech

Add-ins for Inventor!

0 Likes
Message 6 of 6

richie_tony007
Participant
Participant

Thanks Heaps @Ivan_Sinicyn That works but i have modified my code to add the iso full assembly on the first page followed by the parts list and the part drawings

how to add the template for partslist and keep the iso full assembly view only on the 1st sheet.

 

Sub Main()
' Get the active document (must be an assembly)
Dim modelReference As Document = ThisApplication.ActiveDocument

' Check if the active document is an assembly
If modelReference.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
	MessageBox.Show("The active document must be an assembly.")
	Exit Sub
End If

' Create a new drawing
Dim oDrawingDoc As DrawingDocument = CreateSheet()

' Check if the drawing was created successfully
If oDrawingDoc Is Nothing Then
	MessageBox.Show("Failed to create the drawing. Rule execution aborted.")
	Exit Sub
End If

' Pass the model and drawing to create views and the parts list
ShowAssemblyViews(modelReference, oDrawingDoc)
End Sub

Function CreateSheet() As DrawingDocument
	' Specify the path to the template file
	Dim templatePath As String = "C:\_VaultPro\Templates\MKT DESIGN TEMPLATE.dwg"

	' Check if the template file exists
	If Not System.IO.File.Exists(templatePath) Then
		MessageBox.Show("Error: Template file '" & templatePath & "' not found. Ensure the path is correct and the file is accessible.")
		Return Nothing
	End If

	' Try to create a new drawing based on the template
	Try
		Dim oDoc As DrawingDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, templatePath)

		' Activate the first sheet
		Dim oSheet As Sheet = oDoc.Sheets.Item(1)

		' Notify about successful drawing creation
		MessageBox.Show("Drawing successfully created from the template!")

		' Return the created drawing
		Return oDoc
	Catch ex As Exception
		MessageBox.Show("Error creating drawing: " & ex.Message)
		Return Nothing
	End Try
End Function

Sub ShowAssemblyViews(modelReference As Document, oDrawingDoc As DrawingDocument)
	' Check if the document is an assembly
	If modelReference.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
		Dim oAsmDoc As AssemblyDocument = modelReference

		' Get the first sheet (to place the assembly iso view)
		Dim oSheet As Sheet = oDrawingDoc.Sheets.Item(1)

		' Create the isometric view of the full assembly
		CreateAssemblyIsoView(oAsmDoc, oSheet)

		' Create parts list on the second sheet
		CreatePartsList(oAsmDoc, oDrawingDoc)

		' Create unique sheets for individual parts
		ShowPanelParts(oAsmDoc, oDrawingDoc)
	Else
		MessageBox.Show("The provided document is not an assembly.")
	End If
End Sub

Sub CreateAssemblyIsoView(oAsmDoc As AssemblyDocument, oSheet As Sheet)
	' Set the scale for the assembly isometric view
	Dim scale As Double = 1 / 25

	' Define the view location on the sheet
	Dim isoViewHorizontal As Double = (oSheet.Width * 0.25)
	Dim isoViewVertical As Double = (oSheet.Height * 0.5)

	' Create the isometric view
	Dim oIsoViewPoint As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(isoViewHorizontal, isoViewVertical)
	Dim isoViewOrientation As ViewOrientationTypeEnum = kIsoTopRightViewOrientation
	Dim isoViewStyle As DrawingViewStyleEnum = kShadedDrawingViewStyle

	Try
		Dim oIsoView As DrawingView = oSheet.DrawingViews.AddBaseView(oAsmDoc, oIsoViewPoint, scale, isoViewOrientation, isoViewStyle)
		oIsoView.Name = "ASSEMBLY ISOMETRIC VIEW"
	Catch ex As Exception
		MessageBox.Show("Error creating assembly isometric view: " & ex.Message)
	End Try
End Sub

Sub CreatePartsList(oAsmDoc As AssemblyDocument, oDrawingDoc As DrawingDocument)
	Try
		' Get the first drawing view on the first sheet (this should be the full assembly view)
		Dim oSheet As Sheet = oDrawingDoc.Sheets.Item(1)
		Dim oDrawingView As DrawingView = oSheet.DrawingViews.Item(1)

		' Define position for the parts list (on the second sheet)
		Dim oNewSheet As Sheet = oDrawingDoc.Sheets.Add()
		oNewSheet.Name = "Parts List"

		Dim oPosition As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(10, oNewSheet.Height - 10)

		' Create the parts list (BOM) using the assembly drawing view
		Dim oPartsList As PartsList = oNewSheet.PartsLists.Add(oDrawingView, oPosition)

		' Auto arrange and renumber parts
		oPartsList.Renumber()

		' Set the parts list style (optional)
		oPartsList.Style = oDrawingDoc.StylesManager.PartsListStyles.Item("Default")

		MessageBox.Show("Parts list successfully created on the second sheet.")
	Catch ex As Exception
		'        MessageBox.Show("Error creating parts list: " & ex.Message)
	End Try
End Sub


Sub ShowPanelParts(modelReference As Document, oDrawingDoc As DrawingDocument)
    ' Check if the document is an assembly
    If modelReference.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
        Dim oAsmDoc As AssemblyDocument = modelReference
        
        ' Get the first sheet from the template to use as a base
        Dim oBaseSheet As Sheet = oDrawingDoc.Sheets.Item(1)
        
        ' Create a collection for unique part names
        Dim uniqueParts As New Collection
        
        ' Counter for sheet naming
        Dim sheetCounter As Integer = 1
        
        ' Loop through all components in the assembly
        For Each oComp As ComponentOccurrence In oAsmDoc.ComponentDefinition.Occurrences
            If oComp.Suppressed = False Then
                ' Check if the component name contains "PANEL"
                If InStr(oComp.Name, "PANEL") > 0 Then
                    Dim partName As String = oComp.Name.ToUpper()
                    partName = Replace(partName, " LEFT", "")
                    partName = Replace(partName, " RIGHT", "")
                    
                    ' Check if the part is already in the collection
                    Dim isDuplicate As Boolean = False
                    For Each uniquePart As String In uniqueParts
                        If uniquePart = partName Then
                            isDuplicate = True
                            Exit For
                        End If
                    Next
                    
                    ' If the part is unique, add it and create views on a copied sheet
                    If Not isDuplicate Then
                        uniqueParts.Add(partName)
                        
                        ' Copy the base sheet
                        Dim oNewSheet As Sheet = oBaseSheet.CopyTo(oDrawingDoc)
                        oNewSheet.Name = "Sheet " & sheetCounter & " - " & oComp.Name
                        sheetCounter = sheetCounter + 1
                        
                        ' Create views on the copied sheet
                        CreateViews(oComp, oNewSheet)
                        MessageBox.Show("Found part: " & oComp.Name & " - Views created on " & oNewSheet.Name)
                    End If
                End If
            End If
        Next
        
        ' Delete the original first sheet after all operations
'        If oDrawingDoc.Sheets.Count > 1 Then
'            oBaseSheet.Delete()
'            ' Activate the first remaining sheet
'            oDrawingDoc.Sheets.Item(1).Activate()
'        End If
    Else
        MessageBox.Show("The provided document is not an assembly.")
    End If
End Sub

Sub CreateViews(oComp As ComponentOccurrence, oSheet As Sheet)
	' Set the scale for the views of individual parts
	Dim scale As Double = 1 / 12

	' Define the view locations on the sheet
	Dim sheetCenterVertical As Double = (oSheet.Height / 2)
	Dim isoViewHorizontal As Double = (oSheet.Width * 0.25)
	Dim rightViewHorizontal As Double = (oSheet.Width * 0.75)

	' Create points for view placement
	Dim oIsoViewPoint As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(isoViewHorizontal, sheetCenterVertical)
	Dim oRightViewPoint As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(rightViewHorizontal, sheetCenterVertical)

	' Define view orientations
	Dim isoViewOrientation As ViewOrientationTypeEnum = kIsoTopRightViewOrientation
	Dim rightViewOrientation As ViewOrientationTypeEnum = kRightViewOrientation

	' Define view styles
	Dim isoViewStyle As DrawingViewStyleEnum = kShadedDrawingViewStyle
	Dim rightViewStyle As DrawingViewStyleEnum = kHiddenLineRemovedDrawingViewStyle

	' Create views for the component
	Try
		Dim oIsoView As DrawingView = oSheet.DrawingViews.AddBaseView(oComp.Definition.Document, oIsoViewPoint, scale, isoViewOrientation, isoViewStyle)
		oIsoView.Name = oComp.Name & " ISOMETRIC VIEW"

		Dim oRightView As DrawingView = oSheet.DrawingViews.AddBaseView(oComp.Definition.Document, oRightViewPoint, scale, rightViewOrientation, rightViewStyle)
		oRightView.Name = oComp.Name & " RIGHT VIEW"
	Catch ex As Exception
		'        MessageBox.Show("Error creating views for part '" & oComp.Name & "': " & ex.Message)
	End Try
End Sub

 

 

0 Likes