Author Topic: Plot in Inventor  (Read 619 times)

0 Members and 1 Guest are viewing this topic.

sanderson

  • Mosquito
  • Posts: 1
Plot in Inventor
« on: May 24, 2016, 01:28:12 pm »
Hello:
 
I am trying to create a routine to plot in Inventor.
 
When it gets to oSheet.Activate (text in red below), I get a Run-time error 5:  Invalid procedure call or argument.
 
Any help would be appreciated.  I believe the logic is correct, pending any API changes from prior versions.  Can you recommend a good book on API programming?
 
Thanks.
 
Code: [Select]
Private Sub cmdPlot_Click()
    ' Define application
    Dim oApp As Inventor.Application
    Set oApp = ThisApplication

    ' Define document
    Dim oCurrentDoc As DrawingDocument
    Set oCurrentDoc = oApp.ActiveDocument

    ' Define sheets
    Dim oSheets As Sheets
    Set oSheets = oCurrentDoc.Sheets

    Dim oSheet As Sheet
    Set oSheet = oCurrentDoc.Sheets.Item(1)

    ' Define print manager
    Dim oPM As DrawingPrintManager
    Set oPM = oCurrentDoc.PrintManager

    ' Get sheet size
    Dim xx As Integer
    Dim xy As Integer

    Select Case oSheet.Size
        Case kADrawingSheetSize
            xx = (6 * 2.54)
            xy = (3.12 * 2.54)
           
        Case kBDrawingSheetSize
            xx = (12 * 2.54)
            xy = (3.12 * 2.54)
           
        Case kCDrawingSheetSize
            xx = (17 * 2.54)
            xy = (3.12 * 2.54)
           
        Case kDDrawingSheetSize
            xx = (29 * 2.54)
            xy = (3.12 * 2.54)
           
        Case kEDrawingSheetSize
            xx = (37 * 2.54)
            xy = (3.12 * 2.54)
       
    End Select

    For Each oSheet In oSheets
        [color=red]oSheet.Activate[/color]
        ' Create a new sketch on the active sheet
        Dim oSketch As DrawingSketch
        Set oSketch = oCurrentDoc.ActiveSheet.Sketches.Add
       
        ' Open sketch for edit so the texhbox can be created
        oSketch.Edit
       
        Dim oTG As TransientGeometry
        Set oTG = oApp.TransientGeometry
       
        Dim sText As String
        sText = txtStampText.Text
       
        Dim oTextBox As Inventor.TextBox
        Set oTextBox = oSketch.tectboxes.AddFitted(oTG.CreatePoint2d(xx, xy), sText)
       
        oSketch.ExitEdit
       
        ' Requires plot to activate text
        oPM.PrintToFile ("c:\temp\tmpinventor.plot")
       
        ' Predefine printers
        Dim PRN As String
        PRN = "\\PS64\HP Color LaserJet M750dn"
       
        Dim PLT As String
        PLT = "\\PS64\HP T2500"
               
        oPM.ScaleMode = kPrintFullScale
        oPM.PrintRange = kPrintAllSheets
               
        Select Case oSheet.Size
            Case kADrawingSheetSize
                oPM.Printer = PRN
                oPM.PaperSize = kPaperSizeLetter
                oPM.Orientation = kLandscapeOrientation
               
            Case kBDrawingSheetSize
                oPM.Printer = PRN
                oPM.PaperSize = kPaperSize11x17
                oPM.Orientation = kLandscapeOrientation
               
            Case kCDrawingSheetSize
                oPM.Printer = PLT
                oPM.PaperSize = kPaperSizeCSheet
                oPM.Orientation = kLandscapeOrientation
               
            Case kDDrawingSheetSize
                oPM.Printer = PLT
                oPM.PaperSize = kPaperSizeDSheet
                oPM.Orientation = kLandscapeOrientation
               
            Case kEDrawingSheetSize
                oPM.Printer = PLT
                oPM.PaperSize = kPaperSizeESheet
                oPM.Orientation = kLandscapeOrientation
               
        End Select

        oPM.SubmitPrint

        oSketch.Delete
       
    Next

End Sub
 

Yosso

  • Newt
  • Posts: 33
Re: Plot in Inventor
« Reply #1 on: June 29, 2016, 01:25:03 pm »
When I attempt to run I get an error where you are trying to assign a textual value to a undefined sketchsymbol or something.

Code: [Select]
       
Dim sText As String
sText = txtStampText.Text