<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.E-MailFormatvorlage17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=DE link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal><span lang=EN-US>Hello everybody,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>we would like to export an image of a system structure based on our metamodel, similar to the GME “Print to Metafile” function. Since we weren’t able to use the underlying functions of “Print to Metafile” in a transformation, we would like to draw all icons on a canvas and save it to a file. For this, we need to access the icon names of each object.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>The issue is, that in our code the icon name is returned correctly for the first element, e.g. “module.gif” but not for the following ones. Beginning from the second object resp. loop, an error is returned and the value of “icon_value” is always “Aspect”. Following the code:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>##################### CODE START ##########################<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>BSTR icon_path; // "icon"<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>BSTR icon_value; // e.g. "module.gif"<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>std::string str_name, str_icon_name;<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>CComPtr<IUnknown> pUnk;<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>set<Udm_VS10::Object> objs = ModelMain.GetChildObjects();<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>for (set<Udm_VS10::Object>::const_iterator it = objs.begin(); it != objs.end(); it++) <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>{<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> icon_path = L"/icon";<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> SysFreeString(icon_value);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> pUnk.Attach(UdmGme::Udm2Gme( *it ));<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> CComQIPtr<IMgaFCO> pFCO = pUnk;<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> HRESULT hr = pFCO->get_RegistryValue( icon_path, &icon_value);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> </span>_com_error err(hr);<o:p></o:p></p><p class=MsoNormal> LPCTSTR errMsg = err.ErrorMessage();<o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal> <span lang=EN-US>std::string str = BstrToStdString(icon_value);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> std::cout << green << "the icon name is " << str << "error message ::" << errMsg << white << endl;<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> pUnk.Release();<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>};<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>##################### CODE END ##########################<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span lang=EN-US>Could someone please give us a hint or provide a code snippet about how to access the name of the icon resp. use “CComPtr<IUnknown> pUnk” in a correct way?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>And if there is a more simple way of exporting a selection of objects, please let me know too.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Thanks in advance and best regards<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Tim<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p></div></body></html>