Reply
Solved! Go to solution

Is there an alternative to GetObject

[ Edited ]

Hi,

in one of my macros i use GetObject to get a reference to a document. I use the document to get the ViewStyle and FaceStyle information from this file. FullName of the file as String is the only information i have at this moment.

 

source = CType(GetObject(fi.FullName), SolidEdgeDocument)
styler = New CModellStyler(destination, source)

This is the only function i use from Microsoft.VisualBasic Namespace.

Is there an alternative way to get a reference to the document without opening the file (visible) and without using VisualBasic Namespace?

 

Greetings from Germany

 

Christian

Greetings from Germany
Christian Kunkel
https://c-k-m.info
2 REPLIES
Solution
Solution
Accepted by topic author ckunkel72
‎08-26-2015 04:32 AM

Re: Is there an alternative to GetObject

You sure can. GetObject() is not much more than a wrapper for Marshal.BindToMoniker().

 

Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text

Namespace MonikerTest
	Friend Class Program
		Shared Sub Main(ByVal args() As String)
			Dim filename = "C:\Users\jason_001\Desktop\Part1.par"
			Dim document = TryCast(System.Runtime.InteropServices.Marshal.BindToMoniker(filename), SolidEdgeFramework.SolidEdgeDocument)
			Dim application = document.Application
		End Sub
	End Class
End Namespace

 

Jason Newell
Applications Architect
www.jasonnewell.net

Re: Is there an alternative to GetObject

Thank you Jason, works fine.

 

Greetings from Germany

Christian Kunkel

Greetings from Germany
Christian Kunkel
https://c-k-m.info