SE API with C++/Create Part

 

    SolidEdgeFramework::ApplicationPtr pSEApp;

    SolidEdgeFramework:Smiley Very HappyocumentsPtr pDocs;

    SolidEdgePart:Smiley TongueartDocumentPtr pPartDoc;

    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;

    SolidEdgePart::ModelsPtr pModels;

    SolidEdgePart::ModelPtr pModel;

    IDispatchPtr pDispatch;

    HRESULT hr;

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

    pDocs=pSEApp->Documents;

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

    hr=pDispatch->QueryInterface(&pPartDoc);

    pProfileSets=pPartDoc->ProfileSets;

    pProfileSet=pProfileSets->Add();

    pProfiles=pProfileSet->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.06);

    pLines2d->AddBy2Points(0.08,0.06,0.064,0.06);

    pLines2d->AddBy2Points(0.064, 0.06, 0.064, 0.02);

    pLines2d->AddBy2Points(0.064, 0.02, 0.048, 0.02);

    pLines2d->AddBy2Points(0.048, 0.02, 0.048, 0.06);

    pLines2d->AddBy2Points(0.048, 0.06, 0.032, 0.06);

    pLines2d->AddBy2Points(0.032, 0.06, 0.032, 0.02);

    pLines2d->AddBy2Points(0.032, 0.02, 0.016, 0.02);

    pLines2d->AddBy2Points(0.016, 0.02, 0.016, 0.06);

    pLines2d->AddBy2Points(0.016, 0.06, 0, 0.06);

    pLines2d->AddBy2Points(0, 0.06, 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(5),SolidEdgeConstants::KeypointIndexConstants::igLineStart,true);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

 

    pProfile->End(SolidEdgePart:Smiley TonguerofileValidationType::igProfileClosed);

    pProfile->Visible=VARIANT_FALSE;

 

    pModels=pPartDoc->Models;

 

    /*SAFEARRAY *pProfileArray;

    pProfileArray=SafeArrayCreateVector(VT_DISPATCH,0,1);

    SafeArrayPutElement(pProfileArray,0,pProfile);*/

    CComSafeArray pProfileArray(1);

    pProfileArray.SetAt(0,pProfile);

    pModels->AddFiniteExtrudedProtrusion((long)1,pProfileArray.GetSafeArrayPtr()

        ,SolidEdgePart::FeaturePropertyConstants::igRight,0.05,vtMissing,vtMissing,vtMissing);

 

 

Posted by: assassin 007
Post date: 5/16/2010 7:41:42 PM