API Help - Programatically inserted drawing view invisible - why?

Discussion in 'SolidWorks' started by What-a-Tool, Jul 17, 2005.

  1. What-a-Tool

    What-a-Tool Guest

    For the most part, this code works great, but every now and then, I get a
    file where the part is invisible in the view.

    The sheet is there, the view is there, the part is there, because when I run
    my mouse over the view the edges highlight in red and disapear again as I
    move off.

    Before this sheet and view is created, I had created another sheet with 3
    drawing views :
    swDraw.Create3rdAngleViews2(swModel.GetPathName)
    These drawing views (same part, same file), show up fine.

    Anyone have a clue what might be going on here?

    Thanks - Sean



    Private Sub Add_OneToOneSheet(ByVal ParentName As String, _
    ByVal ActvCnfgNm As String)
    On Error GoTo Err_Add_OneToOneSheet

    Dim swMyModel As ModelDoc2
    Dim swMyDrwng As DrawingDoc
    Dim swMySheet As Sheet
    Dim swMyView As View

    Dim vntParSz, vntDwgSz As Variant
    Dim intDwgSize As Integer
    Dim blnRet As Boolean
    Dim sngXLoca, sngYLoca As Single


    Set swMyModel = swApp.ActiveDoc
    Set swMyDrwng = swMyModel

    'This is a function that returns my part size, which is stored in a table
    (working correctly)
    vntParSz = GetPrtSz_FrmTable(ParentName, ActvCnfgNm)
    'This is a function that returns the correct sheet size in relation to my
    part size(working correctly)
    vntDwgSz = GetPaperSize(vntParSz(0), vntParSz(1))
    intDwgSize = vntDwgSz(0)

    If intDwgSize >= 0 Then
    sngXLoca = Inch_to_Meter(vntDwgSz(1) / 2)
    sngYLoca = Inch_to_Meter(vntDwgSz(2) / 2)
    'Create new sheet
    blnRet = swMyDrwng.NewSheet2("FullSizeView", intDwgSize, _
    intDwgSize, 1, 1, False, "", 0, 0)
    Set swMySheet = swMyDrwng.GetCurrentSheet
    'No sheet format
    swMySheet.SheetFormatVisible = False
    Set swMyView = swMyDrwng.CreateDrawViewFromModelView2(ParentName,
    "Current Model View", _
    sngXLoca, sngYLoca, 0)
    swMyView.SetDisplayTangentEdges2 2
    Else
    Exit Sub 'Part is to large to display 1:1 on any paper size
    End If

    Exit_Add_OneToOneSheet:
    Set swMyModel = Nothing
    Set swMyDrwng = Nothing
    Set swMySheet = Nothing
    Set swMyView = Nothing
    Exit Sub
    Err_Add_OneToOneSheet:
    MsgBox Err.Description, , "cslSW_SLDDRW - Add_OneToOneSheet"
    Resume Exit_Add_OneToOneSheet
    End Sub
     
    What-a-Tool, Jul 17, 2005
    #1
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.