• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            C++ Programmer's Cookbook

            {C++ 基礎} {C++ 高級} {C#界面,C++核心算法} {設計模式} {C#基礎}

            arx & c++ 常用函數代碼

             

            1改變實體顏色

            Acad::ErrorStatus
            changeColor(AcDbObjectId entId, Adesk::UInt16 newColor)
            {
                AcDbEntity 
            *pEntity;
                acdbOpenObject(pEntity, entId,
                    AcDb::kForWrite);

                pEntity
            ->setColorIndex(newColor);
                pEntity
            ->close();

                
            return Acad::eOk;
            }


            2打開model空間
            bool OpenWorkingModelSpace()
            {
                Acad::ErrorStatus es ;
                AcDbBlockTable 
            *pBlockTbl ;
                AcDbBlockTableRecord 
            *pp ;
                
            //AcDbObjectId pObjectid;

                
            // Get the block table
                if ( (es =acdbHostApplicationServices ()->workingDatabase ()->getBlockTable (pBlockTbl, AcDb::kForRead)) != Acad::eOk )
                
            {
                    acutPrintf (
            "\nCouldn't open the block table!") ;
                    
            return false;
                }

                
            // Get the Model Space record and open it for read.
                if ( (es =pBlockTbl->getAt (ACDB_MODEL_SPACE, pp, AcDb::kForWrite)) != Acad::eOk )
                
            {
                    acutPrintf (
            "\nCouldn't get Model Space! Drawing corrupt.\n") ;
                    pBlockTbl
            ->close () ;
                    
            return  false;
                }

                pBlockTbl
            ->close ();
                
            //pp即為model的指針
                
            //使用pp
                pp->close();
                
            return true;
            }


            3創建textstyle

            bool CreateTextStyle()
            {
                Acad::ErrorStatus es;
                AcDbTextStyleTable 
            * pTextStyleTable;
                es
            = acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pTextStyleTable, AcDb::kForWrite);
                
            if (es != Acad::eOk) 
                
            {
                    delete pTextStyleTable;
                    
            return false;
                }

                
            if(pTextStyleTable->has("textstyle name"))
                
            {
                    
            //delete pTextStyleRecord;
                    pTextStyleTable->close();
                    
            return true;
                }

                AcDbTextStyleTableRecord 
            * pTextStyleRecord = new AcDbTextStyleTableRecord();
                
            if (pTextStyleRecord == NULL)
                    
            return false;
                

                 es 
            = pTextStyleRecord->setName("Mytablestyle");
                    
            //es = pTextStyleRecord->setFont("@宋體",Adesk::kFalse,Adesk::kFalse,936,FIXED_PITCH );
                   es = pTextStyleRecord->setBigFontFileName("gbcbig.shx");
                   es 
            = pTextStyleRecord->setFileName("txt.shx");
                   
            //es = pTextStyleRecord->setTextSize(2.2);
                    
            //設置屬性
                if (es != Acad::eOk) 
                
            {
                    delete pTextStyleRecord;
                    
            return false;
                }

                es 
            = pTextStyleTable->add(pTextStyleRecord);
                
            if (es != Acad::eOk)
                
            {
                    acutPrintf(
            "not add id");
                    delete pTextStyleRecord;
                    
            return false;
                }

                pTextStyleTable
            ->close();
                pTextStyleRecord
            ->close();
               

                
            return true;
            }


            4增加blockref到model

            bool AddblockrefToModel()
            {

                
            if(pMS == NULL)
                  
            return false;
                AcDbBlockTable 
            *pBlockTable ;
                AcDbObjectId pTitileBlockId;
                
            // Open the block table for read
                Acad::ErrorStatus es ;
                
            if ( (es =acdbHostApplicationServices ()->workingDatabase ()->getBlockTable (pBlockTable, AcDb::kForRead)) != Acad::eOk )
                    
            return false ;

                
            if ( pBlockTable->getAt("xxx",pTitileBlockId) == Adesk::kTrue )
                
            {    
                    
            return false ;
                }

                pBlockTable
            ->close ();

                
                AcDbBlockReference 
            * pTitileBlockRef = new AcDbBlockReference(AcGePoint3d(xx ,yy,zz),pTitileBlockId);
                AcGeScale3d pscale(scale); 
                pTitileBlockRef
            ->setScaleFactors(pscale);
                
            //設置屬性
                
                pMS
            ->appendAcDbEntity(pTitileBlockRef);
                pTitileBlockRef
            ->close();

                
            return true;
                
            }

            5遍歷block中的屬性 
            //與遍歷block中的實體相似
            AcDbObjectIterator *pBlkRefAttItr=pBlkRef->attributeIterator();
            for (pBlkRefAttItr->start(); !pBlkRefAttItr->done();pBlkRefAttItr->step())
            {
            AcDbObjectId attObjId;
            attObjId 
            = pBlkRefAttItr->objectId();

            AcDbAttribute 
            *pAtt = NULL;
            Acad::ErrorStatus es 
            = acdbOpenObject(pAtt, attObjId, AcDb::kForRead);
            if (es != Acad::eOk) 
            {
            acutPrintf(
            "\nFailed to open attribute");
            delete pBlkRefAttItr;
            continue;
            }

            if (strcmp(pAtt->tag(),"TITLE:"== 0)
            {
            CString title 
            = pAtt->textString();
            if (strcmp(title,"PROGRESS(D)"== 0)
            //操作
            }

            else if (strcmp(title,"PROGRESS(P)"== 0)
            {
            //操作
            }

            }

            pAtt
            ->close();
            }

            6公差標注設置函數:
            void SetDimtpAndDimtm(double tp,double tm)
            {
            AcDbDimStyleTable 
            *pDimStyleTbl;
            acdbCurDwg()
            ->getDimStyleTable(pDimStyleTbl,AcDb::kForRead);
            AcDbDimStyleTableRecord 
            *pDimStyleTblRcd;
            pDimStyleTbl
            ->getAt("",pDimStyleTblRcd,AcDb::kForWrite);
            if (fabs(tp) == fabs(tm))
            {
            pDimStyleTblRcd
            ->setDimtfac(1.0)
            }

            else pDimStyleTblRcd->setDimtfac(0.5);
            if (tp == 0.0 && tm == 0.0)
            {
            pDimStyleTblRcd
            ->setDimtol(0);
            }

            else
            {
            pDimStyleTblRcd
            ->setDimtp(tp);
            pDimStyleTblRcd
            ->setDimtol(1);
            pDimStyleTblRcd
            ->setDimtm(tm);
            }

            pDimStyleTblRcd
            ->close();
            pDimStyleTbl
            ->close();
            }

            posted on 2006-02-08 14:08 夢在天涯 閱讀(2294) 評論(1)  編輯 收藏 引用 所屬分類: ARX/DBX

            評論

            # re: arx & c++ 常用函數代碼 2006-02-17 09:03 夢在天涯

            Finding the Active Viewports in Model Space

            // Set some viewport information.
            AcDbViewportTable* pViewportTable;
            if (db.getViewportTable(pViewportTable, AcDb::kForRead)
            == Acad::eOk)
            {
            // Find the first viewport and open it for write.
            AcDbViewportTableRecord *pRecord;
            if (pViewportTable->getAt(
            "*ACTIVE", pRecord,
            AcDb::kForWrite) == Acad::eOk)
            {
            pRecord->setCenterPoint(AcGePoint2d(0.5, 0.5));
            pRecord->setHeight(1.0);
            pRecord->setWidth(1.0);
            pRecord->close();
            }
            pViewportTable->close();
            }
              回復  更多評論   

            公告

            EMail:itech001#126.com

            導航

            統計

            • 隨筆 - 461
            • 文章 - 4
            • 評論 - 746
            • 引用 - 0

            常用鏈接

            隨筆分類

            隨筆檔案

            收藏夾

            Blogs

            c#(csharp)

            C++(cpp)

            Enlish

            Forums(bbs)

            My self

            Often go

            Useful Webs

            Xml/Uml/html

            搜索

            •  

            積分與排名

            • 積分 - 1807622
            • 排名 - 5

            最新評論

            閱讀排行榜

            国产精品久久久久影院色| 国内精品伊人久久久久777| 免费观看久久精彩视频| 青草影院天堂男人久久| 久久精品18| 婷婷伊人久久大香线蕉AV| 亚洲国产成人久久精品影视 | 狠狠久久亚洲欧美专区| 久久精品这里只有精99品| 亚洲国产另类久久久精品黑人| 91久久精一区二区三区大全| 亚洲欧洲久久久精品| 久久综合九色综合精品| 欧美亚洲国产精品久久| 色综合久久88色综合天天| 一本久久a久久精品亚洲| 精品久久久久中文字幕一区| 日韩精品久久无码人妻中文字幕| 久久成人精品| 色综合久久天天综合| 国产精品99久久99久久久| 久久久精品国产免大香伊| 久久精品中文字幕第23页| 伊人久久大香线焦综合四虎| 久久久久亚洲AV成人片| 亚洲成色www久久网站夜月| 性做久久久久久久久老女人| 亚洲综合久久综合激情久久| 久久婷婷五月综合色高清| 亚洲精品美女久久777777| 欧美一区二区久久精品| 欧美午夜A∨大片久久| 久久伊人色| 久久久精品视频免费观看| 国产精品热久久毛片| 国产精品免费久久久久影院 | 久久成人国产精品| A级毛片无码久久精品免费| 亚洲精品无码久久久久去q | 色综合久久中文字幕无码| 久久精品国产亚洲AV蜜臀色欲|