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
Solved! Go to Solution.
It works fine for me.
Maybe you should add the line :
Do you use standard Solid Edge Templates ?
Added it still "Cannot Access File"
And no, we don't use standard templates, I have a feeling this is the problem.
Changed the file location of the templates to the standard templates on my C:\ .
Still cannot access file.
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
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)