que buen aporte @Claudio_Fortunato ! Sepan disculparme mi ignorancia relacionada a Vault, debido a que trabaje sin necesidad de bóveda por algunos años, estoy muy desactualizado en el tema
.
Y es verdad lo que se menciona de la sencillez (y la verdad que a medida que uno agrega cosas las reglas se complican), en este video ejemplificativo, demuestro el uso de una de las reglas mas sencillas "nota general selección " ( tengo otras que se vuelven más complejas porque deben comparar vistas y calcular cual es la vista principal , cual es chapa desplegada, etc, en todas las hojas del conjunto).
Private Sub Main()
Dim tip As Document = ThisDoc.Document
If tip.DocumentType = Inventor.DocumentTypeEnum.kDrawingDocumentObject Then
check_Model
Else
MessageBox.Show("Debe abrir un archivo de dibujo", "Nota General Todo")
End If
End Sub
Sub check_Model
Dim oDoc As DrawingDocument
oDoc = ThisDoc.Document
Dim oSheet As Sheet
oSheet = oDoc.Sheets(1)
Dim oViews As DrawingViews
oViews = oSheet.DrawingViews
Dim n As Integer = oViews.Count
Dim i As Integer
For i = 1 To n
Dim oview As DrawingView =oSheet.DrawingViews.Item(i)
If oview.Name="Model_Data" Then
Agregar_Nota
Exit Sub
Exit For
End If
Next
Insert_MasterView
Agregar_Nota
End Sub
Sub Agregar_Nota
Dim oDoc As DrawingDocument
oDoc = ThisDoc.Document
Dim oSheet As Sheet
oSheet = oDoc.ActiveSheet
Dim oViews As DrawingViews
Dim oView As DrawingView
Line1 :
oView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Seleccione Vista")
If oView Is Nothing Then
Exit Sub
Else
If oView IsNot Nothing Then
oViewModelDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oViewModelName As String = oView.ReferencedDocumentDescriptor.ReferencedDocument.DisplayName
Dim oViewMaster As DrawingView
oViewMaster = oDoc.Sheets(1).DrawingViews.Item(1)
InventorVb.DocumentUpdate()
oViewMasterModelDoc = oViewMaster.ReferencedDocumentDescriptor.ReferencedDocument
oViewMasterModelName = oViewMaster.ReferencedDocumentDescriptor.ReferencedDocument.DisplayName
Dim oBOM As BOM
oBOM = oViewMasterModelDoc.ComponentDefinition.BOM
' Set the structured view to 'all levels'
oBOM.StructuredViewFirstLevelOnly = False
' Make sure that the structured view is enabled.
oBOM.StructuredViewEnabled = True
' Make sure that the parts only view is enabled.
oBOM.PartsOnlyViewEnabled = True
' Establece el tipo de lista de materiales, estructurado o solo partes
If oViewModelDoc.DocumentType = Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then
Dim oBOMView As BOMView
oBOMView = oBOM.BOMViews.Item(1)'Model data
Call ListItems(oBOMView.BOMRows, 0, oViewModelName, oView)
End If
If oViewModelDoc.DocumentType = Inventor.DocumentTypeEnum.kPartDocumentObject Then
Dim oBOMView As BOMView
oBOMView = oBOM.BOMViews.Item(3)'Model data
Call ListItems(oBOMView.BOMRows, 0, oViewModelName, oView)
End If
End If
End If
GoTo Line1
End Sub
Sub ListItems(Rows As BOMRowsEnumerator, indent As Integer,oViewModelName As String,oView As DrawingView)
Dim oBOMRow As BOMRow
sFont = "ISOCPEUR" ' "ISOCP_IV25"
For Each oBOMRow In Rows
Dim rDoc As Inventor.Document
rDoc = oBOMRow.ComponentDefinitions.Item(1).Document
Dim rDocName As String = rDoc.DisplayName
If rDocName <> oViewModelName Then
If Not oBOMRow.ChildRows Is Nothing Then
Call ListItems(oBOMRow.ChildRows, indent + 1,oViewModelName,oView )
End If
Else
If rDoc.DocumentType = Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then tipo="Ensamble: "
If rDoc.DocumentType = Inventor.DocumentTypeEnum.kPartDocumentObject Then tipo="Pieza: "
Cod= iProperties.Value(oViewModelName, "Custom", "C")'iProperties.Value(oModelName, "Project", "Part Number")
n1 = oBOMRow.ItemQuantity
sFSize1 = 0.25 'font size in cm
Código = "<StyleOverride Font='" & sFont & "' FontSize='" & sFSize1 & "' Bold='True'>" _
&"Código: " & "<Property Document='model' PropertySet='User Defined Properties' Property='C' " & _
"FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' >C</Property></StyleOverride>"
Provisión = "<StyleOverride Font='" & sFont & "' FontSize='" & sFSize1 & "' Bold='True'>" _
&"Provisión: " & "<Property Document='model' PropertySet='User Defined Properties' Property='P' " & _
"FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' >P</Property></StyleOverride>"
Descripción ="<StyleOverride Font='" & sFont & "' FontSize='" & sFSize1 & "' Bold='True'><Property Document='model' PropertySet='Design Tracking Properties' Property='Description' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='29'>DESCRIPTION</Property></StyleOverride>"
d1= "<StyleOverride Font='" & sFont & "' FontSize='" & sFSize1 & "' Bold='True'>"& tipo & "</StyleOverride>"
d2= "<StyleOverride Font='" & sFont & "' FontSize='" & sFSize1 & "' Bold='True'>Cantidad: </StyleOverride>"
d3= "<StyleOverride Font='" & sFont & "' FontSize='" & sFSize1 & "' Bold='True'>"& n1 & "</StyleOverride>"
oView.Label.FormattedText = Código & "<Br/>" _
& d1 & Descripción & "<Br/>" _
& Provisión & "<Br/>" _
& d2 & d3
CentText = ThisApplication.TransientGeometry.CreatePoint2d(oView.Center.X , oView.Center.Y + oView.Height/2 + sFSize1*12)
oView.Label.Position= CentText
oView.Label.HorizontalJustification = HorizontalTextAlignmentEnum.kAlignTextLeft
oView.ShowLabel = True
End If
Next
End Sub
Sub Insert_MasterView
Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
oSheet = oDoc.ActiveSheet
SheetWidth=ActiveSheet.Width/10 'sheet units in cm
SheetHeight = ActiveSheet.Height/10 'sheet units in cm
oTG = ThisApplication.TransientGeometry
oPoint1 = oTG.CreatePoint2d(SheetWidth/2, SheetHeight/2)' view insert point
' Create a new FileDialog object.
Dim oFileDlg As Inventor.FileDialog
ThisApplication.CreateFileDialog(oFileDlg)
oFileDlg.Filter = "Archivo de ensamblaje (*.iam)|*.iam"
oFileDlg.FilterIndex = 1
oFileDlg.DialogTitle = "Seleccione ENSAMBLAJE PRINCIPAL para extraer cantidades de piezas"
oFileDlg.InitialDirectory = oTLoc
oFileDlg.InsertMode = False
oFileDlg.MultiSelectEnabled = False
oFileDlg.SuppressResolutionWarnings = True
oFileDlg.CancelError = False
oFileDlg.ShowOpen
Dim oViewModelDoc As Document
oViewModelDoc = ThisApplication.Documents.Open(oFileDlg.FileName, False)
Dim NewView As DrawingView
NewView =oDoc.Sheets.Item(1).DrawingViews.AddBaseView(oViewModelDoc, oPoint1, 0.05, ViewOrientationTypeEnum.kIsoBottomLeftViewOrientation, DrawingViewStyleEnum.kShadedDrawingViewStyle, "Default")
NewView.Suppressed = True
NewView.Name = NewView.Name.ToUpper.Replace(NewView.Name, "Model_Data")
End Sub
Esta es una de las reglas más sencillas acerca de la cantidad, ya que solo hay que seleccionar la vista donde se cargaran los datos en edit view label, seguramente la regla no les funcione porque yo tengo cargadas las propiedades personalizadas de "C" código del elemento, "P" Provisión del elemento, donde a su vez hay cargados parámetros de medida de cada pieza. Por ello la regla es orientativa, tal vez podría enfocar un método más efectivo.
Saludos colegas!
Please accept as solution and give likes if applicable.
I am attaching my Upwork profile for specific queries.
Sergio Daniel Suarez
Mechanical Designer
| Upwork Profile | LinkedIn