Reply

Draft Document Open Code Additional questions

Here I tried using the forum post code.
Below is the code.

-------------------------------------------

Imports System.Runtime.InteropServices

Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim objApp As SolidEdgeFramework.Application = Nothing
Dim objRev As RevisionManager.Application = Nothing
Dim objRevDft As RevisionManager.Document = Nothing
Dim objDocuments As SolidEdgeFramework.Documents = Nothing
Dim objDocument As SolidEdgeFramework.SolidEdgeDocument = Nothing
Dim objPart As SolidEdgePart.PartDocument = Nothing
Dim objdraft As SolidEdgeDraft.DraftDocument = Nothing

Dim pathname As String
Dim partname As String
Dim dftname As String

Try
objApp = Marshal.GetActiveObject("SolidEdge.Application")
objRev = CreateObject("RevisionManager.Application")
objDocument = objApp.ActiveDocument
pathname = objDocument.Path.ToString ' Edited into code
partname = objDocument.FullName
objRev.WhereUsedCriteria("*.dft", True) = pathname
objRevDft = objRev.FindWhereUsed(partname)
If IsNothing(objRevDft) Then
Call objApp.StartCommand(CommandID:=39001)
Me.Close()
'Application.DoEvents()
End If
dftname = objRevDft.FullName
Me.Close()
objApp.Visible = True
objDocuments = objApp.Documents
objPart = objDocuments.Open(objRevDft.FullName)

'Application.DoEvents()
Catch ex As Exception
Finally
If Not (objApp Is Nothing) Then
Marshal.ReleaseComObject(objApp)
objApp = Nothing
End If
If Not (objRev Is Nothing) Then
Marshal.ReleaseComObject(objRev)
objRev = Nothing
End If
If Not (objRevDft Is Nothing) Then
Marshal.ReleaseComObject(objRevDft)
objRevDft = Nothing
End If
If Not (objDocuments Is Nothing) Then
Marshal.ReleaseComObject(objDocuments)
objDocuments = Nothing
End If
If Not (objDocument Is Nothing) Then
Marshal.ReleaseComObject(objDocument)
objDocument = Nothing
End If
If Not (objPart Is Nothing) Then
Marshal.ReleaseComObject(objPart)
objPart = Nothing
End If
If Not (objdraft Is Nothing) Then
Marshal.ReleaseComObject(objdraft)
objdraft = Nothing
End If

End Try
Me.Close()
End Sub
End Class

-------------------------------------------


The problem is that the parent path is not found in the path where the part document is located.
Can I modify it to search higher than the current path?
Is there a way?

2 REPLIES

Re: Draft Document Open Code Additional questions

[ Edited ]

A quick Google search indicates there is a get parent method for a directory path, so you might be able to do it that way.

 

see here...

 

I think this is the bit of code that does the work, where 'path' is the current path string

 

        Sub GetParent(ByVal path As String)
            Try
                Dim directoryInfo As System.IO.DirectoryInfo
                directoryInfo = System.IO.Directory.GetParent(path)
                System.Console.WriteLine(directoryInfo.FullName)
            Catch exp As ArgumentNullException
                System.Console.WriteLine("Path is a null reference.")
            Catch exp As ArgumentException
                System.Console.WriteLine("Path is an empty string, " + _
                                     "contains only white spaces, or " + _
                                     "contains invalid characters.")
            End Try
        End Sub

 

HP Z420 16GB RAM
Quadro K4000
ST7 MP10 on Windows 7 Pro 64.

Re: Draft Document Open Code Additional questions

Thank you for your reply.
Let's test it with this code.