• <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 夢在天涯 閱讀(2283) 評論(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

            搜索

            •  

            積分與排名

            • 積分 - 1804159
            • 排名 - 5

            最新評論

            閱讀排行榜

            久久精品国产91久久综合麻豆自制| www性久久久com| 久久这里有精品| 久久久久久毛片免费播放| 四虎国产永久免费久久| 无码8090精品久久一区| 亚洲午夜无码久久久久| 99久久精品免费| 久久综合狠狠综合久久综合88| 久久精品国产一区二区三区日韩| 久久久久亚洲精品无码网址 | 色综合色天天久久婷婷基地| 久久99亚洲综合精品首页| 久久亚洲精品无码aⅴ大香| 嫩草影院久久99| 亚洲综合精品香蕉久久网| 久久本道综合久久伊人| 99久久99久久| 亚洲AV无码久久精品成人| 久久久久九国产精品| 国产人久久人人人人爽| 囯产精品久久久久久久久蜜桃| 成人午夜精品久久久久久久小说 | 国産精品久久久久久久| 国产精品99久久99久久久| 中文字幕久久精品| 国内精品久久久久久久coent| .精品久久久麻豆国产精品| 99精品久久久久久久婷婷 | 久久久免费精品re6| 97精品伊人久久久大香线蕉| 亚洲国产成人久久精品99| 欧美午夜A∨大片久久| 国产69精品久久久久9999| 青青青青久久精品国产h| 久久婷婷国产麻豆91天堂| 99久久人妻无码精品系列蜜桃| 午夜精品久久久久久毛片| 久久天天躁狠狠躁夜夜躁2O2O| 精品熟女少妇AV免费久久| 亚洲精品乱码久久久久66|