[great-users] Reading out GUID and Object ID of current object

Kevin Smyth ksmyth at isis.vanderbilt.edu
Thu Aug 21 09:59:03 CDT 2014


Dominik,

I tested this code with the GReAT sample House2Order. I modified the 
AttributeMapping /zt_House2Order/MakeOrder1/CreateOrder, and set up the 
configuration to use MakeOrder1 instead of MakeOrder3.

Getting the id-000-style id is easy. Unfortunately, getting the GUID 
requires the COM interface.

// id-000....-style id
std::string gmeId = UdmGme::UdmId2GmeId(PurchaseOrder.uniqueId());

// GUID
CComPtr<IUnknown> pUnk;
pUnk.Attach(UdmGme::Udm2Gme(PurchaseOrder)); // caveat: Udm2GME returns 
NULL if PurchaseOrder is a Udm XML object
CComQIPtr<IMgaFCO> pFCO = pUnk; // caveat: pFCO will be NULL if 
PurchaseOrder is a Folder. (You could use IMgaObject instead)
_bstr_t bstrGuid;
pFCO->GetGuidDisp(bstrGuid.GetAddress());

PurchaseOrder.name() = std::string("PurchaseOrder") + static_cast<const 
char*>(bstrGuid) + gmeId;
// caveat: the static_cast uses the current code page. It should instead 
be UTF-8, since Udm strings are UTF-8
// PurchaseOrder.name() == 
PurchaseOrder{ec439575-02fa-48e0-a5cd-02e21c1c6ced}id-0065-00000001


This code requires 2 include files:

<?xml version="1.0" encoding="UTF-16"?>
<!DOCTYPE clipboard SYSTEM "mga.dtd" [
     <!ELEMENT clipboard 
(folder|model|atom|reference|set|connection|regnode)*>
     <!ATTLIST clipboard
         acceptingkind CDATA #IMPLIED
         paradigmnamehint CDATA #IMPLIED
     >
]>
<clipboard paradigmnamehint="UMLModelTransformer">
     <atom id="id-0066-0000003e" kind="UserCodeLibrary" 
role="UserCodeLibrary">
         <name>UserCodeLibrary</name>
         <attribute kind="IncludeFiles">
             <value>atlbase.h;mga.h</value>
         </attribute>
         <attribute kind="IncludePath">
             <value>C:\Program Files (x86)\GME\Interfaces</value>
         </attribute>
     </atom>
</clipboard>


Hope this helps.

Kevin

On 8/21/2014 8:00 AM, Dominik Giel wrote:
> Dear users of GReAT,
> today I want you to ask a question about accessing the GUID and 
> ObjectID of an object, I am currently using in a rule of my 
> GReAT-Transformation.
> I just need to read it and save the information in a variable, no 
> write-access is needed. I just want to save the information of the 
> object like it is displayed in GME into a variable.
> Is there a function provided, where I can access the GUID and ObjectID 
> which I can implement in an attribute mapping to write this 
> information into a variable?
> I would be pleased, if someone of you could help me out with this. 
> Thanks in advance for your help.
> Greetings from Germany,
> Dominik Giel
> --
> Dominik Giel
> ILS - Institute of Airborne Systems
> University of Stuttgart
> dominik.giel at gmx.de
>
>
> _______________________________________________
> great-users mailing list
> great-users at list.isis.vanderbilt.edu
> http://list.isis.vanderbilt.edu/mailman/listinfo/great-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://list.isis.vanderbilt.edu/pipermail/great-users/attachments/20140821/65d0b0da/attachment.html 


More information about the great-users mailing list