Hi
I have a rule that make 2d Drawing for all my stps in specific Path , send to print , and close the stp file.
How can i call this Class ? i made it by diferents ways but don work
If a run the Class directly , i dont have problem
This is my main Rule , and i have other rules to make this into all the files in a specific Path
Imports Inventor.ViewOrientationTypeEnum
Imports Inventor.DrawingViewStyleEnum
Imports System.Windows.Forms
Dim oDrawingDoc as DrawingDocument
Dim oPartDoc as Document
Dim oSheet As sheet
Dim oView1 as DrawingView
Dim oView2 as DrawingView
Dim oView3 as DrawingView
Dim oView4 as DrawingView
' Obtener la medida en cada eje , con precision de 2 decimales.
Medidaenx=Round(Measure.ExtentsLength,2)
Medidaeny=Round(Measure.ExtentsWidth,2)
Medidaenz=Round(Measure.ExtentsHeight,2)
' Se obtiene el nombre del STP sin la extension.
Dim name As String
name=ThisDoc.FileName(False)
' Se evalua las 3 medidas de bloque x , y , z y se obtiene la mayor , dicha medida se divide por el factor y esa es la escala de las vistas
Escala=MaxOfMany(medidaenx, medidaeny, medidaenz)
ViewScale = 91/escala
oPartDoc = ThisDoc.Document
'Check to see if part is a sheetmetal part
If oPartDoc.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
'do nothing
Else
'ensure this part has a flat pattern
Dim oSMDef As SheetMetalComponentDefinition
oSMDef = oPartDoc.ComponentDefinition
If oSMDef.FlatPattern Is Nothing Then
'create flat pattern
oSMDef.Unfold
oSMDef.FlatPattern.ExitEdit
oSMDef.FlatPattern.FlipBaseFace
Else
'do nothing
End If
End If
'Se define la ubicacion del Template
oDrawingDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, "O:\Operaciones\Maquinado\OTs\FFA-01-19 Dibujo estandar.idw", True)
oSheet = oDrawingDoc.Sheets.Item(1)
' Create a new NameValueMap object
Dim oBaseViewOptions As NameValueMap
oBaseViewOptions = ThisApplication.TransientObjects.CreateNameValueMap
'True = folded view False = flat pattern view
oBaseViewOptions.Add("SheetMetalFoldedModel", False)
'Se define el punto inferior izquierdo para cada una de las vistas
oPoint1 = ThisApplication.TransientGeometry.CreatePoint2d(9, 10) ' front view
oPoint2 = ThisApplication.TransientGeometry.CreatePoint2d(9, 20) ' top view
oPoint3 = ThisApplication.TransientGeometry.CreatePoint2d(28, 10)' right view
oPoint4 = ThisApplication.TransientGeometry.CreatePoint2d(28, 20)' iso
' Se abre un sketch para generar los textos
Dim oSketch As DrawingSketch
oSketch = oDrawingDoc.ActiveSheet.Sketches.Add
' Open the sketch for edit so the text boxes can be created.
' This is only required for drawing sketches, not part.
oSketch.Edit
Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry
' Se define el texto y posiciona el texto Medidas de corte
Dim sText1 As String
sText1 ="Medidas de corte "
Dim oTextBox1 As inventor.TextBox
oTextBox1 = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(36, 24), sText1)
' Se define y posiciona el texto con los valores de bloque
Dim sText As String
sText =" X "& medidaenx & " Y" & medidaeny & " Z" & medidaenz
Dim oTextBox As inventor.TextBox
oTextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(36, 23), sText)
' Se define y pocisiona el texto con el nombre del archivo
Dim oTextbox2 As inventor.Textbox
oTextbox2 = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(9, 26), name)
' Se da formato a los textos
oTextbox.Formattedtext = "<StyleOverride FontSize='" & .4 & "'>" _
& oTextbox.Text & "</StyleOverride>"
oTextbox1.Formattedtext = "<StyleOverride FontSize='" & .4 & "'>" _
& oTextbox1.Text & "</StyleOverride>"
oTextbox2.Formattedtext = "<StyleOverride FontSize='" & .4 & "'>" _
& oTextbox2.Text & "</StyleOverride>"
' Se posicionan las vistas
oBaseView = oSheet.DrawingViews.AddBaseView(oPartDoc,oPoint1, ViewScale,kFrontViewOrientation, kHiddenLineDrawingViewStyle, "My View")
oView2 = oSheet.DrawingViews.AddProjectedView(oBaseView,oPoint2, kHiddenLineDrawingViewStyle, ViewScale)
oView3 = oSheet.DrawingViews.AddProjectedView(oBaseView,oPoint3, kHiddenLineDrawingViewStyle, ViewScale)
oView4 = oSheet.DrawingViews.AddProjectedView(oBaseView,oPoint4, kHiddenLineDrawingViewStyle, (ViewScale/1.15))
' Se cierra el Sketch
oSketch.ExitEdit