设为首页收藏本站

中国膜结构网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

膜结构车棚
膜结构车棚膜结构资质国产膜材 膜结构网中国膜结构协会
查看: 50|回复: 3

arx函数

[复制链接]
  • TA的每日心情
    开心
    2021-6-18 10:57
  • 签到天数: 1538 天

    [LV.Master]伴坛终老

    发表于 2021-5-22 21:33 | 显示全部楼层 |阅读模式
    //------------------------------------------------------------------------------
    Acad::ErrorStatus ZoomTo(AcGePoint2d& Min, AcGePoint2d& Max, double dZoomFactor)
    //------------------------------------------------------------------------------
    {
            Acad::ErrorStatus es = (Acad::ErrorStatus)-1;
            // Check zoom makes sense
            if ((Max.y - Min.y) > 0.001 || (Max.x - Min.x) > 0.001)
            {
                    AcDbViewTableRecord mVTR;
                    mVTR.setCenterPoint(Min + (Max - Min) / 2.0);
                    mVTR.setHeight((Max.y - Min.y) * dZoomFactor);
                    mVTR.setWidth((Max.x - Min.x) * dZoomFactor);
                    es = acedSetCurrentView(&mVTR, NULL);
            }
            return es;
    }
    回复


    http://www.mjgw.org/ 专业从事膜结构设计、制作加工、施工安装的膜结构工程服务,能够为客户提供专业的膜结构整体解决方案。做中国最好的膜结构综合服务平台。欢迎大家联系电话:198-7840-1958,QQ:463017170.
    相关关键词:膜结构车棚,膜结构车棚覆盖,膜结构车棚公司,膜结构车棚多少钱,膜结构车棚厂家,膜结构车棚价格,社区膜结构车棚,膜结构车棚膜布厂家 ,膜结构车棚哪家好,膜结构车棚多少钱一米,膜结构车棚报价,膜结构车棚哪里有,膜结构车棚定制,膜结构车棚安装,膜结构车棚设计,膜结构车棚电话,膜结构车棚加工,膜结构车棚膜布价格,膜结构车棚批发,膜结构车棚制造商,膜结构车棚生产厂家,膜结构车棚设计,膜结构车棚施工,膜结构车棚多少钱一平米,膜结构车棚订制,张拉膜车棚,张拉膜车棚覆盖,张拉膜车棚公司,张拉膜车棚多少钱,张拉膜车棚厂家,张拉膜车棚价格,社区张拉膜车棚,张拉膜车棚膜布厂家 ,张拉膜车棚哪家好,张拉膜车棚多少钱一米,张拉膜车棚报价,张拉膜车棚哪里有,张拉膜车棚定制,张拉膜车棚安装,张拉膜车棚设计,张拉膜车棚电话,张拉膜车棚加工,张拉膜车棚膜布价格,张拉膜车棚批发,张拉膜车棚制造商,张拉膜车棚生产厂家,张拉膜车棚设计,张拉膜车棚施工,张拉膜车棚多少钱一平米,张拉膜车棚订制,常用膜材品牌:德国杜肯、法国法拉利、德国海德斯、德国米乐、日本平岗、韩国秀博、比利时希运、美国赫虏伯、中国科宝、上海慧遥。

    使用道具 举报

  • TA的每日心情
    开心
    2021-6-18 10:57
  • 签到天数: 1538 天

    [LV.Master]伴坛终老

     楼主| 发表于 2021-5-22 21:33 | 显示全部楼层

    arx函数

    //------------------------------------------------------------------------------
    void Goto(double dX, double dY, BOOL bZoom)
    //------------------------------------------------------------------------------
    {
            Acad::ErrorStatus es = Acad::eOk;

            AcDbDatabase* pDb = pApp->GetCurrentAcDb();

            if (pDb != NULL)
            {
                    // Get the viewport
                    es = acedVports2VportTableRecords();
                    AcDbViewportTable *pVpT = NULL;
                    AcDbViewportTableRecord *pActVp = NULL;
                    AcGePoint2d centerpt;
                    double height = 0.0L;
                    double width = 0.0L;

                    // Get the *Active view port
                    es = pDb->getViewportTable(pVpT, AcDb::kForRead);
                    if (pVpT != NULL)
                    {
                            es = pVpT->getAt(_T("*ACTIVE"), pActVp, AcDb::kForWrite);
                            es = pVpT->close();

                            if (pActVp != NULL)
                            {
                                    centerpt = pActVp->centerPoint();
                                    height = pActVp->height();
                                    width = pActVp->width();

                                    // Close the Active viewport
                                    es = pActVp->close();

                                    // Update the viewport
                                    es = acedVportTableRecords2Vports();
                            }
                    }

                    // Notify
                    CString sMsg = _T("");
                    sMsg.Format(RESSTR(IDS_MOVINGTO), dX, dY);
                    pApp->DisplayMessage(0, sMsg);

                    // This is the same as ZoomTo - but without the unit conversion
                    centerpt.x = dX;
                    centerpt.y = dY;

                    // Adjust for UCS
                    acdbUcs2Wcs((double*)(&centerpt), (double*)(&centerpt), false);

                    // Adjust zoom state based on design size if required
                    DocSettings* pDocSettings = pApp->GetDocSettings();
                    if (bZoom && pDocSettings != NULL)
                    {
                            DistanceUnit unit;
                            pApp->GetUnitSettings()->GetUserUnit(&unit);
                            DocSettings:esignSizes Sizes = pDocSettings->GetDesignSizes();
                            double basesize = Sizes.m_BaseSymbolSize.GetConvertedValue(unit);

                            (height > 10.0L * basesize) ? height = 10.0L * basesize : height;
                            (width > 10.0L * basesize) ? width = 10.0L * basesize : width;
                    }

                    // Got specified point
                    if (height > 0.001 || width > 0.001)
                    {
                            AcDbViewTableRecord mVTR;
                            mVTR.setCenterPoint(centerpt);
                            mVTR.setHeight(height);
                            mVTR.setWidth(width);
                            es = acedSetCurrentView(&mVTR, NULL);
                    }
            }
    }
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    开心
    2021-6-18 10:57
  • 签到天数: 1538 天

    [LV.Master]伴坛终老

     楼主| 发表于 2021-5-22 21:35 | 显示全部楼层
    int getTextUnderLinePoint()
    {
    int res = 0;

    ads_point pickpt;
    ads_name ename;
    int sel_test = acedEntSel(_T("Select Text :"), ename, pickpt);

    if (sel_test != RTNORM)
    return res;


    ads_point min_pt_tmp;
    ads_point max_pt_tmp;
    AcDbObjectId ObjId;

    resbuf *pResBuf = NULL;
    pResBuf = acdbEntGet(ename);
    int stat = acedTextBox(pResBuf, min_pt_tmp, max_pt_tmp);
    Point2D min_pt = ads_point_2_Point2D(min_pt_tmp);
    Point2D max_pt = ads_point_2_Point2D(max_pt_tmp);
    double DiagonalDist = getDiagonalDist(min_pt, max_pt);

    Acad::ErrorStatus es = acdbGetObjectId(ObjId, ename);

    if (es !=Acad::eOk)
    return res;

    AcDbEntity *pEntity = NULL;
    Acad::ErrorStatus open_status = acdbOpenObject(pEntity, ObjId, AcDb::kForRead);

    if (open_status != Acad::eOk)
    return res;

    if (pEntity->isA() == AcDbText::desc())
    {
    AcDbText* pText=AcDbText::cast(pEntity);

    TCHAR* contents = pText->textString();
    Point2D TextPos = AcGePoint3d_2_Point2D(pText->position());

    double TextHeight = pText->height();
    double TextWidth = getTextWidth(TextHeight, DiagonalDist);
    double rot_angle = pText->rotation();

    AcGePoint3d zero_point;
    AcDbMText* mtext = new AcDbMText;
    mtext->setLocation(zero_point);
    mtext->setWidth(TextWidth);
    mtext->setHeight(TextHeight);
    mtext->setContents(contents);

    transformToWcs(mtext, acdbHostApplicationServices()->workingDatabase());
    AcGePoint3dArray pts_array;
    mtext->getBoundingPoints(pts_array);
    int size = pts_array.length();

    vector<Point2D> PtsV;
    for(int i=0; i<size; i++)
    {
    Point2D pt = AcGePoint3d_2_Point2D(pts_array[i]);
    PtsV.push_back(pt);
    }
    delete mtext;



    Point2D u_p1 = *(PtsV.begin()+2); // leftbottom
    Point2D u_p2 = *(PtsV.begin()+3); // rightbottom
    Point2D u_mid = MidPoint(u_p1, u_p2); // get middlepoint

    Point2D rot_u_p1 = RotPoint2(u_mid, u_p1, rot_angle);
    Point2D rot_u_p2 = RotPoint2(u_mid, u_p2, rot_angle);

    double delta_x = TextPos.x - rot_u_p1.x;
    double delta_y = TextPos.y - rot_u_p1.y;

    Point2D res_pt1 = MovePoint(rot_u_p1, delta_x, delta_y);
    Point2D res_pt2 = MovePoint(rot_u_p2, delta_x, delta_y);



    }
    pEntity->close();

    return 1;
    }



    double getTextWidth(double TextHeight, double DiagonalDist)
    {
    return sqrt((DiagonalDist*DiagonalDist) - (TextHeight*TextHeight));
    }



    Point2D RotPoint2(Point2D basePt, Point2D pt, double theta)
    {
    Point2D respt;
    pt.x += -basePt.x;
    pt.y += -basePt.y;

    double X,Y;
    X=pt.x; Y=pt.y;

    pt.x=X*(cos(theta)) - Y*(sin(theta));
    pt.y=Y*(cos(theta)) + X*(sin(theta));

    pt.x+= basePt.x;
    pt.y+= basePt.y;

    respt.x=pt.x;
    respt.y=pt.y;
    return respt;
    }
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    开心
    2021-6-18 10:57
  • 签到天数: 1538 天

    [LV.Master]伴坛终老

     楼主| 发表于 2021-5-22 21:36 | 显示全部楼层
    AcGePoint3d ptA(3,4,5);
    AcGePoint3d ptB(4,5,6);
    AcGePoint3d ptC(2,2,2);

    AcGePlane planeTarget(ptA, ptB, ptC);
    AcGeVector3d vecNormal = planeTarget.normal();
    double dElevation = AcGePoint3d::kOrigin.distanceTo(AcGePoint3d::kOrigin.orthoProject(planeTarget));

    AcDbHatch* pHatch = new AcDbHatch();
    Acad::ErrorStatus es = pHatch->setElevation(dElevation); assert(es==Acad::eOk);
    es = pHatch->setNormal(vecNormal); assert(es==Acad::eOk);

    AcGeMatrix3d mxECS;
    pHatch->getEcs(mxECS);
    mxECS.invert();

    AcGePoint2d pt2A = ptA.transformBy(mxECS).convert2d(AcGePlane::kXYPlane);
    AcGePoint2d pt2B = ptB.transformBy(mxECS).convert2d(AcGePlane::kXYPlane);
    AcGePoint2d pt2C = ptC.transformBy(mxECS).convert2d(AcGePlane::kXYPlane);

    AcGePoint2dArray rpt2Loop;
    rpt2Loop.append(pt2A);
    rpt2Loop.append(pt2B);
    rpt2Loop.append(pt2C);
    rpt2Loop.append(pt2A);

    es = pHatch->appendLoop(AcDbHatch::kExternal, rpt2Loop, AcGeDoubleArray()); assert(es==Acad::eOk);
    es = pHatch->setPattern(AcDbHatch::kPreDefined, ACRX_T("SOLID")); assert(es==Acad::eOk);
    es = pHatch->evaluateHatch(); assert(es==Acad::eOk);

    AcDbBlockTableRecord* pSpace = NULL;
    if (Acad::eOk == acdbOpenObject(pSpace, acdbCurDwg()->currentSpaceId(), AcDb::kForWrite))
    {
            es = pSpace->appendAcDbEntity(pHatch); assert(es==Acad::eOk);
            pSpace->close();
            pHatch->close();
    }
    else
            delete pHatch;
    回复 支持 反对

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    关闭

    推荐膜材品牌上一条 /6 下一条

    进口膜材 国产膜材 pvdf膜材ptfe膜材ETFE膜材
    最好的膜结构公司 一级膜结构资质 膜结构一级资质
    膜结构设计-膜结构十大品牌-etfe设计-充气膜结构
    诺科膜结构
    遨都膜结构设计
    中国膜结构网
    中国空间膜结构

    QQ|申请友链|手机版|中国膜结构论坛