Create Drawing Views vb.net

Builder
Builder

Hi, currently converting the Surf And Code:Cust 36 : Drawing Views : Vb.net ,wich automatically create 4 views for a part, to a create a flat pattern view for a .psm. I think I got this right but there's a error that occurs at the < oDocD = oDocs.Add("solidEdge.DraftDocument")> line.

Imports System
Imports SolidEdgeFramework
Imports System.Runtime.InteropServices
Imports SolidEdgeGeometry
Imports SolidEdgePart
Imports SolidEdgeConstants
Imports SolidEdgeFrameworkSupport
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Public Class Form1
    Dim oApp As SolidEdgeFramework.Application
    Dim oDocs As SolidEdgeFramework.Documents

    Dim oDocD As SolidEdgeDraft.DraftDocument
    Dim oDocP As SolidEdgePart.SheetMetalDocument

    Dim oSheet As SolidEdgeDraft.Sheet
    Dim oView As SolidEdgeDraft.DrawingView
    Dim oMlink As SolidEdgeDraft.ModelLink
    Dim dopen As OpenFileDialog = New OpenFileDialog()

    Dim sParFile As String, sDftFile As String

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        dopen.Filter = "Solid Edge Part Files (*.psm)|*.psm"
        dOpen.ShowDialog()
        sParFile = dOpen.FileName
        TextBox1.Text = sParFile
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        oApp = Marshal.GetActiveObject("SolidEdge.Application")
        oDocs = oApp.Documents
        oDocP = oDocs.Open(sParFile)
        oDocD = oDocs.Add("SolidEdge.DraftDocument")
        oSheet = oDocD.ActiveSheet
        oMlink = oDocD.ModelLinks.Add(sParFile)
        oView = oSheet.DrawingViews.AddPartView(oMlink, SolidEdgeDraft.ViewOrientationConstants.igFrontView, 1, 0, 0, SolidEdgeDraft.SheetMetalDrawingViewTypeConstants.seSheetMetalFlatView)
        sDftFile = sParFile.ToUpper.Replace("PSM", "DFT")
        oDocD.SaveAs(sDftFile)
        oDocP.Close(False)
    End Sub
End Class

The .psm opens but I get a pop up window in solidedge st7 saying "Cannot acces file" than comes back to the VB.net codes when I click OK and I get the ComException was unhandled error.Probably just cause I cant acces the file, but what file the DraftDocument?Should I write something else than DraftDocument?

Any little help will be greatly aprreciated. PRobably from Thushar since it was his Tutorial to start with Smiley Happy

ST9
Conveyor and industrial equipment designer.
Giving SE a chance.
6 REPLIES

Re: Create Drawing Views vb.net

Builder
Builder

This is the warning I get.

ST9
Conveyor and industrial equipment designer.
Giving SE a chance.

Re: Create Drawing Views vb.net

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

Hi,

 

It works fine for me.

 

Maybe you should add the line :

Imports SolidEdgeDraft

 

Do you use standard Solid Edge Templates ?


Romuald BERTIN

Re: Create Drawing Views vb.net

Builder
Builder

Added it still "Cannot Access File"

And no, we don't use standard templates, I have a feeling this is the problem.

ST9
Conveyor and industrial equipment designer.
Giving SE a chance.

Re: Create Drawing Views vb.net

Builder
Builder

Changed the file location of the templates to the standard templates on my C:\ .

Still cannot access file.

ST9
Conveyor and industrial equipment designer.
Giving SE a chance.

Re: Create Drawing Views vb.net

Builder
Builder

Ok Finally had to go into the template folder and open one of the templates, then and only then did I have "access" to it and now the program works. Some kind of weird surver problem that blocks our files even when there on our c:

Thanks every one for your attention.Specially Mr. Bertin

ST9
Conveyor and industrial equipment designer.
Giving SE a chance.

Re: Create Drawing Views vb.net

Builder
Builder

Here's the right code line to create the flat pattern view of the sheetmetal:

oView = oSheet.DrawingViews.AddSheetMetalView(oMlink, SolidEdgeDraft.DrawingViewTypeConstants.igPrincipleView, 1, 0, 0, SolidEdgeDraft.SheetMetalDrawingViewTypeConstants.seSheetMetalFlatView)
ST9
Conveyor and industrial equipment designer.
Giving SE a chance.