Reply

Getting Item ID/ Rev of active Draft Doc

[ Edited ]

 

Hi,

Can someone please advise as to how can I get the Item ID / Rev number of an active Draft Document which I have opened from Teamcenter using Solid Edge Embddded client.

Regards,

Kalpesh

 

 

Posted by: KALPESH PARMAR
Post date: 1/31/2008 6:18:53 AM

8 REPLIES

RE: Getting Item ID/ Rev of active Draft Doc

[ Edited ]

I figured this out.

 

Item ID = Document Number ( File Properties -> Project Tab )

Rev No = Revision Number ( File Properties -> Project Tab )

 

But, then ..

 

HRESULT MyFunction(ApplicationPtr pSEApp,DraftDocumentPtr pDrfDoc)

{

 

PropertySetsPtr pPropSet ;

PropertiesPtr pProperties;

PropertyPtr pProperty;

 

pPropSet = PropertySetsPtr(pDrfDoc->Properties);

pProperties = pPropSet->Item("Project"); // It fails here.....??? What am I missing ? pPropSet->Item("Custom") works fine.

 

 

 

 

 

Posted by: KALPESH PARMAR
Post date: 1/31/2008 9:21:49 AM

RE: Getting Item ID/ Rev of active Draft Doc

[ Edited ]

 

Hi Kalpesh,

 

Try pPropSet->Item("ProjectInformation");  or maybe "Project Information"...

 

Cheers

Calum

 

Posted by: Calum McLellan
Post date: 1/31/2008 10:17:51 AM

RE: Getting Item ID/ Rev of active Draft Doc

[ Edited ]

Thanks !!

ProjectInformation ( without space ) works !!

 

By the way, where is this documented ?

 

How do I extract the value of the Property Document Number & Revision Number ? I got it going but the value of document number which I am getting is 0017EC34 while the actual Document Number string is "P-654718.1"

 

HRESULT MyFunction(ApplicationPtr pSEApp,DraftDocumentPtr pDrfDoc)

{

 

PropertySetsPtr pPropSet ;

PropertiesPtr pProperties;

PropertyPtr pProperty;

 

_variant_t PropValue;

 

pPropSet = PropertySetsPtr(pDrfDoc->Properties);

 

pProperties = pPropSet->Item("ProjectInformation");

PropValue = pProperty->Value;

cout

 

Posted by: KALPESH PARMAR
Post date: 1/31/2008 11:38:19 AM

RE: Getting Item ID/ Rev of active Draft Doc

[ Edited ]

 

Kalpesh,

 

If you have not done so already, download and install my Solid Edge Spy. It's a free download in the Products link. It visualizes the runtime COM object model of Solid Edge. It will help you learn the API much quicker.

Your code should look something like thisHRESULT MyFunction(ApplicationPtr pSEApp,DraftDocumentPtr pDrfDoc) { SolidEdgeFramework:Smiley TongueropertySetsPtr pPropertySets = NULL; SolidEdgeFramework:Smiley TongueropertiesPtr pProperties = NULL; SolidEdgeFramework:Smiley TongueropertyPtr pProperty = NULL; pPropertySets = pDrfDoc->Properties; pProperties = pPropertySets->Item(_T("ProjectInformation")); pProperty = pProperties->Item(_T("Document Number")); _variant_t vtValue = pProperty->GetValue(); cout

 

Posted by: Jason Newell
Post date: 1/31/2008 12:26:05 PM

RE: Getting Item ID/ Rev of active Draft Doc

[ Edited ]

 

Hi Jason,

I realised that there was some typo in the source code that I had posted,  which gave the impression that I am not able to appreciate the Object Model of SE.

I had missed this line...

pProperty = pProperties->Item(_T("Document Number"));& also I was calling the GetValue() method on pProperty & not the Value property. This line too had typo. 

Anyway, thanks for the reply.  I will be more careful in future posts.

Additionally this is what I found....

cout bstrVal

gives out put ...................   Document Number =00179BBC

 

cout operator_bstr_t()

give output .....................Document Number =8007831.1

 

 

 

 

 

 

 

Posted by: KALPESH PARMAR
Post date: 1/31/2008 12:35:40 PM

RE: Getting Item ID/ Rev of active Draft Doc

[ Edited ]

In the code fragrement above, how does one set the Document Number?

 

The line below works for Custom properties, but not for "ProjectInformation" and "Document Number".

pProperties->Add(_T(vtProperty),_T(vtValue));

 

 

 

Posted by: Tom Slossar
Post date: 3/24/2008 12:37:07 PM

RE: Getting Item ID/ Rev of active Draft Doc

[ Edited ]

 

Tom,

See if this helps.

// SEPropDemo.cpp : Defines the entry point for the console application.//#include "stdafx.h"int _tmain(int argc, _TCHAR* argv[]){ CoInitialize(NULL); SolidEdgeFramework::ApplicationPtr pApplication = NULL; SolidEdgeFramework:Smiley FrustratedolidEdgeDocumentPtr pDocument = NULL; SolidEdgeFramework:Smiley TongueropertySetsPtr pPropertySets = NULL; SolidEdgeFramework:Smiley TongueropertiesPtr pProperties = NULL; SolidEdgeFramework:Smiley TongueropertyPtr pProperty = NULL; pApplication.GetActiveObject(_T("SolidEdge.Application")); pDocument = pApplication->ActiveDocument; pPropertySets = pDocument->Properties; // Demo looping through all properties for (LONG i = 1; i Count; i++) { pProperties = pPropertySets->Item(i); _bstr_t propertySetName(pProperties->Name); for (LONG j = 1; j Count; j++) { pProperty = pProperties->Item(j); _bstr_t propertyName(pProperty->Name); } } // Demo changing the Document Number property pProperties = pPropertySets->Item(_T("ProjectInformation")); pProperty = pProperties->Item("Document Number"); _variant_t docNumber(_T("123-456")); pProperty->PutValue(&docNumber); pProperty = NULL; pProperties = NULL; pPropertySets = NULL; pDocument = NULL; pApplication = NULL; CoUninitialize(); return 0;}

 

Posted by: Jason Newell
Post date: 3/24/2008 12:57:33 PM

RE: Getting Item ID/ Rev of active Draft Doc

[ Edited ]

That took care of it. When .NET displayed the methods available it listed "put_Value", and when I used that I had a link error. Any ideas of why the mismatch?

 

I also downloaded your Spy program and will see if I can get some use out of it. Thank you very much.

 

Posted by: Tom Slossar
Post date: 3/25/2008 6:39:07 AM