Reply

SE API with C++/Variable

[ Edited ]

 

    SolidEdgeFramework::ApplicationPtr pSEApp;

    SolidEdgePart:Smiley TongueartDocumentPtr pPartDoc;

    SolidEdgeFramework::VariablesPtr pVars;

    SolidEdgeFramework::variablePtr pVar;

    IDispatchPtr pDispatch;

    HRESULT hr;

    hr=pSEApp.GetActiveObject("SolidEdge.Application");

    pDispatch=pSEApp->ActiveDocument;

    hr=pDispatch->QueryInterface(&pPartDoc);

    pDispatch=pPartDoc->Variables;

    hr=pDispatch->QueryInterface(&pVars);

    _variant_t unitType;

    unitType.intVal=1;

    pDispatch=pVars->Add((_bstr_t)"NewVar",(_bstr_t)"1.5",&unitType/*(int)SolidEdgeFramework::UnitTypeConstants::igUnitDistance*/);

    hr=pDispatch->QueryInterface(&pVar);

    double x; CString TmpStr;

    x=sin(0.1);

    TmpStr.Format("%.3d",x);

    pVar->Formula=(_bstr_t)TmpStr;

    pVar->Name="NewName";

    pVar->Value=123;

    pVar->Formula="456";

    pVar->Value=789;

    pVars->Edit((_bstr_t)"NewName",(_bstr_t)"333");

    pDispatch=pVars->Item((_bstr_t)"NewName");

    hr=pDispatch->QueryInterface(&pVar);

    pVar->Value=0.02;

 

Posted by: assassin 007
Post date: 5/16/2010 7:43:14 PM