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

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)
End If
dftname = objRevDft.FullName
objApp.Visible = True
objDocuments = objApp.Documents
objPart = objDocuments.Open(objRevDft.FullName)

Catch ex As Exception
If Not (objApp Is Nothing) Then
objApp = Nothing
End If
If Not (objRev Is Nothing) Then
objRev = Nothing
End If
If Not (objRevDft Is Nothing) Then
objRevDft = Nothing
End If
If Not (objDocuments Is Nothing) Then
objDocuments = Nothing
End If
If Not (objDocument Is Nothing) Then
objDocument = Nothing
End If
If Not (objPart Is Nothing) Then
objPart = Nothing
End If
If Not (objdraft Is Nothing) Then
objdraft = Nothing
End If

End Try
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?


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)
                Dim directoryInfo As System.IO.DirectoryInfo
                directoryInfo = System.IO.Directory.GetParent(path)
            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.