SE API with C++/Place dimension and change it via varialbe

 

    SolidEdgeFramework::ApplicationPtr pSEApp;

    SolidEdgeFramework:Smiley Very HappyocumentsPtr pDocs;

    SolidEdgePart:Smiley TongueartDocumentPtr pPartDoc;

    SolidEdgePart:Smiley FrustratedketchsPtr pSketchs;

    SolidEdgePart:Smiley FrustratedketchPtr pSketch;

    SolidEdgePart:Smiley TonguerofileSetsPtr pProfileSets;

    SolidEdgePart:Smiley TonguerofileSetPtr pProfileSet;

    SolidEdgePart:Smiley TonguerofilesPtr pProfiles;

    SolidEdgePart:Smiley TonguerofilePtr pProfile;

    SolidEdgePart::RefPlanesPtr pRefPlanes;

    SolidEdgeFrameworkSupport::Relations2dPtr pRelations2d;

    SolidEdgeFrameworkSupport::Relation2dPtr pRelation2d;

    SolidEdgeFrameworkSupport::Lines2dPtr pLines2d;

    SolidEdgeFrameworkSupport::Line2dPtr pLine2d;

    SolidEdgeFrameworkSupport:Smiley Very HappyimensionsPtr pDims;

    SolidEdgeFrameworkSupport:Smiley Very HappyimensionPtr pDim1,pDim2;

    IDispatchPtr pDispatch;

    HRESULT hr;

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

    pDocs=pSEApp->Documents;

    pDispatch=pDocs->Add("SolidEdge.PartDocument",vtMissing);

    hr=pDispatch->QueryInterface(&pPartDoc);

    pSketchs=pPartDoc->Sketches;

    pSketch=pSketchs->Add();

 

    pProfiles=pSketch->Profiles;

    pRefPlanes=pPartDoc->RefPlanes;

    pProfile=pProfiles->Add(pRefPlanes->Item((long)3));

 

    pLines2d=pProfile->Lines2d;

    pLines2d->AddBy2Points(0,0,0.08,0);

    pLines2d->AddBy2Points(0.08,0,0.08,0.1);

    pLines2d->AddBy2Points(0.08,0.1,0,0.1);

    pLines2d->AddBy2Points(0,0.1,0,0);

 

    pDispatch=pProfile->Relations2d;

    hr=pDispatch->QueryInterface(&pRelations2d);

    pRelations2d->AddKeypoint(pLines2d->Item(1),SolidEdgeConstants::KeypointIndexConstants::igLineEnd,

                              pLines2d->Item(2),SolidEdgeConstants::KeypointIndexConstants::igLineStart,true);

 

    pRelations2d->AddKeypoint(pLines2d->Item(2),SolidEdgeConstants::KeypointIndexConstants::igLineEnd,

                              pLines2d->Item(3),SolidEdgeConstants::KeypointIndexConstants::igLineStart,true);

    pRelations2d->AddKeypoint(pLines2d->Item(3),SolidEdgeConstants::KeypointIndexConstants::igLineEnd,

                              pLines2d->Item(4),SolidEdgeConstants::KeypointIndexConstants::igLineStart,true);

    pRelations2d->AddKeypoint(pLines2d->Item(4),SolidEdgeConstants::KeypointIndexConstants::igLineEnd,

                              pLines2d->Item(1),SolidEdgeConstants::KeypointIndexConstants::igLineStart,true);

 

    pDims=pProfile->Dimensions;

    pDim1=pDims->AddLength(pLines2d->Item(1));

    pDim1->Constraint=VARIANT_TRUE;

    pDim2=pDims->AddDistanceBetweenObjects(pLines2d->Item(1),0.1,0.1,0,VARIANT_FALSE

        ,pLines2d->Item(3),0,0.05,0,VARIANT_FALSE);

    pDim2->Constraint =    VARIANT_TRUE;

 

    SolidEdgeFramework::VariablesPtr pVars;

    SolidEdgeFramework::variablePtr pVar;

    pVars=pPartDoc->Variables;

    pVars->PutName(pDim1,(_bstr_t)"Length");

 

    CString Dim2Str;

    Dim2Str=pVars->GetName(pDim2).Detach();

    pVars->Edit((_bstr_t)Dim2Str,(_bstr_t)"Length/2.0");

 

    pDim1=pVars->Translate((_bstr_t)"Length");

 

Posted by: assassin 007
Post date: 5/16/2010 7:45:05 PM