chinajhl 发表于 2003-12-1 12:00:00

Arx图层问题,困惑几天了。

提一个很菜的问题。
我在ARX程序中新建了一个图层,怎样在程序中将其设置为当前层?

yfy2003 发表于 2003-12-1 13:02:00

http://bbs.mjtd.com/forum.php?mod=viewthread&tid=12132

王咣生 发表于 2003-12-2 17:07:00

回复

参考:
void createNewLayer(char* lyrname, Adesk::UInt16 clr, AcDbObjectId ltypeId, Adesk::Boolean current)
{
        // We need to check if the layer name exists
        // If the layer name exists, apply the color
        // linetype id and whither to make it current
        // or not. In order to be current it cannot be
        // frozen, so we need to check for this also.
        // If the layer name does not exist we just create
        // a new layer with the properties contained in the arguments
       
        AcDbLayerTable *pLyrTable;
        AcDbLayerTableRecord *pLyrTblRecord;
        AcDbObjectId recId;

        AcCmColor color;
        color.setColorIndex(clr); // set color to parameter clr

        AcDbDatabase *pCurDb = NULL;

        pCurDb = acdbHostApplicationServices()->workingDatabase();


        pCurDb->getLayerTable(pLyrTable, AcDb::kForRead);
        // Check to see if the layer name exists
        if(pLyrTable->has(lyrname))
        {
                pLyrTable->getAt(lyrname, pLyrTblRecord, AcDb::kForWrite, Adesk::kFalse);
                // pLyrTblRecord now points at the layer table record
                // which was opened for write
                pLyrTblRecord->setIsFrozen(Adesk::kFalse);
                pLyrTblRecord->setColor(color);
                pLyrTblRecord->setLinetypeObjectId(ltypeId);

        }
        else
        {
                // Note how we can change the open mode
                // of the layer table from AcDb::kForRead
                // to AcDb::kForWrite

                pLyrTable->upgradeOpen();
                pLyrTblRecord = new AcDbLayerTableRecord;

                pLyrTblRecord->setName(lyrname);
                pLyrTblRecord->setColor(color);
                pLyrTblRecord->setLinetypeObjectId(ltypeId);

                pLyrTable->add(pLyrTblRecord);

        }

        // Get the layer Table ObjectId
        recId = pLyrTblRecord->objectId();

        pLyrTblRecord->close();
        pLyrTable->close();

        // Set the layer current if current
        // is equal to Adesk::kTrue
        // pCurDb is point to the current
        // drawing database
        // The database AcDbDatabase has a number of
        // query and edit functions for the header variables

        if(current)
        {
                pCurDb->setClayer(recId);
        }
}

王咣生 发表于 2003-12-2 17:08:00

回复

chinajhl 发表于 2003-12-8 10:42:00

谢谢,使用setVar已经解决了。
页: [1]
查看完整版本: Arx图层问题,困惑几天了。