admin@creocustomization.com

How to create a drawing from the base template using Creo VB API

How to create a drawing from the base template using Creo VB API

Using Creo VB API developer can automatically create a drawing from predefined template. Usually template is the drawing file with basic part view, dimension and notes. when we call the updated or new part with varying dimension, we can use the existing template to follow the rules.

Here the procedure to do this

  1. Create session from IpfscAsyncConnection
  2. Create a model descriptor from the model file name
  3. Create drawing options
  4. Create drawing from the template (use drawing name without extension and template name with extension)
  5. Now create model descriptor from the drawing file name and open it in the base session

Sample Code here for reference

 Private Sub btn_CreateDrawing_Click(sender As Object, e As RoutedEventArgs)
        Try
            BSession = AConnection.Session

            Dim CModelDescriptor As New CCpfcModelDescriptor
            Dim IModelDescriptor As IpfcModelDescriptor = CModelDescriptor.CreateFromFileName("model_name.prt")

            Dim CDrawingCreateOptions As New CpfcDrawingCreateOptions
            CDrawingCreateOptions.Insert(0, EpfcDrawingCreateOption.EpfcDRAWINGCREATE_DISPLAY_DRAWING)
            CDrawingCreateOptions.Insert(0, EpfcDrawingCreateOption.EpfcDRAWINGCREATE_SHOW_ERROR_DIALOG)
            Dim MyDrawing As IpfcDrawing = BSession.CreateDrawingFromTemplate("drawing_name", "template_name.drw",
             IModelDescriptor, CDrawingCreateOptions)

            Dim MyModelDescriptor As IpfcModelDescriptor = CModelDescriptor.CreateFromFileName("drawing_name.drw")
            BSession.OpenFile(MyModelDescriptor)
        Catch ex As Exception
            MessageBox.Show(ex.ToString, "Failure")
        End Try
    End Sub

Leave a Reply

Contact Us