leven50 发表于 2024-10-28 17:40:11

【初级教程八】抽壳

本帖最后由 leven50 于 2024-10-31 14:59 编辑

一、抽壳         
         概念:抽壳命令构造具有有限厚度的抽壳实体零件,该零件可具有或也可不具有开放面。
https://pingcode.xindicode.com/atlas/files/public/6654444fad4e589b72e08a61/origin-url?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWRfZm9yX3B1YmljX2ltYWdlIjoiNDVkYmM4OWRkNTA2NDg2NWEwODE0MzIxMzRkNTA1OGMiLCJ0ZWFtX2Zvcl9wdWJsaWNfaW1hZ2UiOiI2NDNlN2YxNDgzZTVhNDVkNzdkYzY2MzMiLCJpc19pbnRlcm5hbF90b2tlbiI6dHJ1ZSwiaWF0IjoxNzMwMTA3NzM4LCJleHAiOjE3MzAxMTg1Mzh9.JlRUXI4U47w8czvx1YgFXv81Bv5jTMtd78s4W1hVLQc
         API:
ThinwallPtr Add(
    enum FeaturePropertyConstants ThicknessSide,//FeaturePropertyConstants常量集的成员,该常量集指定偏移边(内部、外部或对称)。
    double CommonThickness,//指定没有唯一厚度的所有面的厚度。该值必须大于零。
    const _variant_t& OpenFaces = vtMissing,//指定要删除或打开的面
    const _variant_t& NumberOfUniqueThicknesses = vtMissing,
    const _variant_t& UniqueThicknessesArray = vtMissing,
    const _variant_t& UniqueThicknessFaceListArray = vtMissing);         示例代码:
void AddThinWalls()
{
    Application* application = TGAddinApp::GetTGApp()->GetApplication();
    TGPart::PartDocumentPtr pDoc = application->GetActiveDocument();
    // 新建草图
    TGPart::SketchPtr pSketch = pDoc->Sketches->Add();
    //参考平面
    TGPart::RefPlanePtr pRefplane = pDoc->GetRefPlanes()->Item(3);
    // 轮廓
    TGPart::ProfilePtr pProfile = pSketch->GetProfiles()->Add(pRefplane);
    // 创建一个中线点为(0.0,0.0),长度为0.1,宽度为0.08的矩形
    CreateRectangle(pProfile);
    CComSafeArray<IDispatch*> aProfiles(1);
    aProfiles = pProfile;
    // 基于矩形去进行拉伸,右侧拉伸、长度为0.05
    TGPart::ModelPtr model = pDoc->Models->AddFiniteExtrudedProtrusion(
      1,
      aProfiles.GetSafeArrayPtr(),
      TGPart::FeaturePropertyConstants::igRight,
      0.05);
    TGGeometry::FacesPtr pSideFaces = (TGGeometry::FacesPtr)(model->GetExtrudedProtrusions()->Item(1)->GetSideFaces());
    // 需要开放的面
    IDispatchPtr s = pSideFaces->Item(1);
    _variant_t OpenFaces(static_cast<IDispatch*>(s));
    // 抽壳操作,开放一个面,厚度为0.01
    ThinwallsPtr pThinwalls = pDoc->Models->Item(1)->GetThinwalls();
    ThinwallPtr pThinwall = pThinwalls->Add(FeaturePropertyConstants::igOutside, 0.01, OpenFaces);
}         示例效果:

https://pingcode.xindicode.com/atlas/files/public/66543b32ad4e589b72e08a35/origin-url?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWRfZm9yX3B1YmljX2ltYWdlIjoiNDVkYmM4OWRkNTA2NDg2NWEwODE0MzIxMzRkNTA1OGMiLCJ0ZWFtX2Zvcl9wdWJsaWNfaW1hZ2UiOiI2NDNlN2YxNDgzZTVhNDVkNzdkYzY2MzMiLCJpc19pbnRlcm5hbF90b2tlbiI6dHJ1ZSwiaWF0IjoxNzMwMTA3NzM4LCJleHAiOjE3MzAxMTg1Mzh9.JlRUXI4U47w8czvx1YgFXv81Bv5jTMtd78s4W1hVLQc

页: [1]
查看完整版本: 【初级教程八】抽壳