acoka兄,我把例子里面的代码改了,可是有错:
例子里面代码如下:
boolean CAATpiCreateTextCmd::CreateTextOnSelection (void * ipData)
{
// Retrieve the selected geometry
CATSO * pSelection = _pAgentGeometry ->GetListOfValues();
if ( pSelection )
{
// Retrieve CATITPSFactoryAdvanced interfaces
CATITPSFactoryAdvanced * piFactAdv = NULL;
HRESULT rc = CATTPSInstantiateComponent (DfTPS_ItfTPSFactoryAdvanced,
(void**) [$ piFactAdv)]
if ( SUCCEEDED(rc) )
{
CATITPSText * piText = NULL;
CATUnicodeString TextString("Sample 3D Text");
CATMathPlane Plane = CATMathOIJ;
rc = piFactAdv -> CreateTextOnGeometry (pSelection, &lane,
[$TextString , &piText)]
……
由于我要在自己生成的点上作标注,所以就像你说的,new了一个CATSO*,代码如下:
boolean ChildCmd1::CreateTextOnGeometry(CATISpecObject_var spPointAsSpec)
{
cout<<cout<<"CreateTextOnGeometry called !!!"<<endl;
// Retrieve the selected geometry
CATBaseUnknown* pPointAsBaseUnknown = spPointAsSpec;
CATSO * pSelection = new CATSO(0);
pSelection->AddElement(pPointAsBaseUnknown,0);
if ( pSelection==NULL ) cout<<endl<<cout<<"pSelection==NULL"<<endl;
if ( pSelection!=NULL )
{
// Retrieve CATITPSFactoryAdvanced interfaces
CATITPSFactoryAdvanced * piFactAdv = NULL;
HRESULT rc =CATTPSInstantiateComponent (DfTPS_ItfTPSFactoryAdvanced,
(void**) [$ piFactAdv)]
if ( SUCCEEDED(rc) )
{
cout<<endl<<cout<<"piFactAdv!=NULL"<<endl;
CATITPSText * piText = NULL;
CATUnicodeString TextString("Sample 3D Text");
CATMathPlane Plane = CATMathOIJ;
rc = piFactAdv -> CreateTextOnGeometry (pSelection, NULL,
[$TextString , &piText)]
……
可是到这句CATIA就退出了:
rc = piFactAdv -> CreateTextOnGeometry (pSelection, NULL,
[$TextString , &piText)]
请问怎么解决呢? |