[TS7] Opening non-TopSolid files using TopSolid API

All topics about specific development with COM interface, LIP language, API in VB, ...

Moderators: remi77, jacs, Daniel

MonkeySleeve
Private
Private
Posts: 5
Joined: Thu Nov 17, 2016 10:24 am
TopSolid Module: TopSolid'Design
TopSolid Version: 6.26

[TS7] Opening non-TopSolid files using TopSolid API

Unread post by MonkeySleeve »

Hi everyone,

I'm currently developing a program which allows us to save information in a TopSolid project(Client name, contact information, project data etc) and one of the features is to being able to import attachments into TopSolid using the Documents.Import method.

This works great; it imports my file into TopSolid(like a PDF) and i can open it in TopSolid by double clicking it. If i however want to open it from my application, it seems dat Documents.Open only works with TopSolid Documents.

I can't seem to open a simple PDF file that is sitting in my TopSolid project via my application. I load in a list of documents that my project has and display them in a Listbox. When selecting a document the user can press a 'open document' button to open the selected file. TopSolid documents work fine but anything other than that i keep getting an exception.

My code:

Code: Select all

 //Get the PdmObjectId
 PdmID = Controller.DocumentList(Index)
 
 //Try and get the document using the PdmObjectId, this returns Empty if it can't get the Document, like a PDF
 DocID = TopSolidHost.Documents.GetDocument(PdmID)
 
 //Open the selected document. This gives me an exception since DocID is empty
 TopSolidHost.Documents.Open(DocID)
 
Is there a way to open a non-TopSolid file using the TopSolid API?
Mark Oostveen
Chief
Chief
Posts: 107
Joined: Mon Mar 26, 2007 9:40 am
TopSolid Module: TopSolid'Cam
TopSolid Version: 6.26
Location: The netherlands
Contact:

Re: [TS7] Opening non-TopSolid files using TopSolid API

Unread post by Mark Oostveen »

Of course. Do not try to use a TopSolid function. As you have a seperate program you can use a shell execute function to start the file using the associated windows program. Just before opening check the file type and see if it is a TopSolid supported file.
MonkeySleeve
Private
Private
Posts: 5
Joined: Thu Nov 17, 2016 10:24 am
TopSolid Module: TopSolid'Design
TopSolid Version: 6.26

Re: [TS7] Opening non-TopSolid files using TopSolid API

Unread post by MonkeySleeve »

Mark Oostveen wrote:Of course. Do not try to use a TopSolid function. As you have a seperate program you can use a shell execute function to start the file using the associated windows program. Just before opening check the file type and see if it is a TopSolid supported file.
Hehe was wondering if you might answer this question :P

I've build in an if statement that checks the objecttype of a document:

Code: Select all

aObjectType = TopSolidHost.Pdm.GetType(PdmID, outExtension)

If (Not aObjectType = PdmObjectType.Unknown) And (Not aObjectType = PdmObjectType.UnknownDocument) Then
      'GetDocument only returns DocumentID if the object is a TopSolid Document
      DocID = TopSolidHost.Documents.GetDocument(PdmID)
Else
But i'm not sure how i can use the shell execute function since i don't have the direct link to a document(Like; "C:/example.pdf"). Can i retrieve this if i have the PdmObjectId?
Post Reply