找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 1332|回复: 1

如何用ARX得到SUMMARY 信息...

[复制链接]

已领礼包: 145个

财富等级: 日进斗金

发表于 2002-1-10 18:16:49 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
HOW DO I MANIPULATE SUMMARY INFO WITH OBJECTARX? (ACDBDATABASESUMMARYINFO)

See Also: SignPost Contents SignPost Index

Product AUTOCAD  Author MCAULEY,CHARLES
Date 26-MAR-99  Document ID 29075
Expiration date    Attachments 29075.zip
Keywords ARX; NOD; SUMMARY

Developer Consulting Group technical solution. Autodesk confidential, for ADN members only. Please read the disclaimer

Question


How do I manipulate Summary Information with ObjectARX
(AcDbDatabaseSummaryInfo)?


Answer


Summary Information in an AutoCAD 2000 drawing is stored as an AcDbXrecord in
the Named Objects Dictionary with the key 'DWGPROPS'. ObjectARX 2000 provides a
wrapper class to manipulate this information, namely AcDbDatabaseSummaryInfo.
This class comes with a number of 'query' and 'edit' functions. Please note that
in a new drawing there will be no 'DWGPROPS' key and associated AcDbXrecord
object. If the user executes the '_DWGPROPS' and accepts 'OK' in the presented
dialog, then AutoCAD will create an AcDbXrecord object in the Named Objects
Dictionary with the key 'DWGPROPS'. Classes closely associated with
AcDbDatabaseSummaryInfo are AcDbSummaryInfoManager and AcDbSummaryInfoReactor.
The AcDbSummaryInfoManager class allows for the addition and removal of
AcDbSummaryInfoReactor objects to the AutoCAD session. The
AcDbSummaryInfoReactor class allow the user to respond to
'summaryInfoHasChanged()' events.  When executing the '_DWGPROPS' command
('File' menu, select 'Drawing Properties...'), the user is presented with a
tabbed style dialog, familiarize yourself with the various tabs before
considering the code presented below. If you have familiarized with the various
tabs on the 'DWGPROPS' dialog, the member functions of the
AcDbDatabaseSummaryInfo class are pretty straightforward in that they mimic
their dialog counterparts. Prior to executing this code make sure that there is
a drawing file that contains Summary Information.


// The registered command is 'GETSUMMINFO'
// Note: minimal to no error checking
void getSummInfo()
{
    // TODO: Implement the command
    Acad::ErrorStatus es;
    AcDbDatabaseSummaryInfo *pInfo;
    AcDbDatabase *pCurDb = NULL;
    AcDbDictionary* pDict;
    char* info;
    char* key;
    char* value;
    int customQty;
    int index;

    // You need to make sure that 'acsiobj.arx' is loaded
    // this is required. acsiobj.arx is an AutoCAD 2000 arx app
    if (!acrxDynamicLinker->loadModule("acsiobj.arx", 0))
    {
        acutPrintf("\nFailed to load the required SummaryInfo
object.\n");
        return;
    }

    pCurDb = acdbHostApplicationServices()->workingDatabase();

    // Get the Named Objects Dictionary
    es = pCurDb->getNamedObjectsDictionary(pDict, AcDb::kForRead);
    // Is there a "DWGPROPS" key
    if(!pDict->has("DWGPROPS"))
    {
        acutPrintf("\nThis drawing does not contain Summary
Information");
        pDict->close();
        return;
    }

    pDict->close();

    // Get a pointer to the workingDatabase() summary information
    es = acdbGetSummaryInfo(pCurDb, pInfo);

    acutPrintf("\nSummary information for this drawing:");

    es = pInfo->getTitle(info);
    if(info)
    {
        acutPrintf("\nTitle = %s", info);
    }

    es = pInfo->getSubject(info);
    if(info)
    {
        acutPrintf("\nSubject matter = %s", info);
    }

    es = pInfo->getAuthor(info);
    if(info)
    {
        acutPrintf("\nAutor = %s", info);
    }

    es = pInfo->getKeywords(info);
    if(info)
    {
        acutPrintf("\nKeywords = %s", info);
    }

    es = pInfo->getComments(info);
    if(info)
    {
        acutPrintf("\nComments = %s", info);
    }

    es = pInfo->setLastSavedBy("Captain CAD");
    es = pInfo->getLastSavedBy(info);
    acutPrintf("\nLast saved by = %s", info);

    es = pInfo->getHyperlinkBase(info);
    if(info)
    {
        acutPrintf("\nLink Location = %s", info);
    }

    es = pInfo->setRevisionNumber("1"); // Note: its a string
    es = pInfo->getRevisionNumber(info);
    acutPrintf("\nRevision number = %s", info);


    customQty = pInfo->numCustomInfo();

    if(customQty > 0)
    {
        acutPrintf("\n\nDrawing Custom Summary Information:\n");
        acutPrintf("\nKey\t\tValue\n");
        for(index = 0; index < customQty; index++)
        {
            pInfo->getCustomSummaryInfo(index, key, value);
            if(key)
            {
                acutPrintf("\n%s", key);
            }
            if(value)
            {
                acutPrintf("\t\t%s", value);
            }

            acdbFree(key);
            acdbFree(value);
        }
    }
    else
    {
        acutPrintf("\n\nDrawing does not contain any Custom Summary
Information");
    }

    es = acdbPutSummaryInfo(pInfo);

    acdbFree(info);
  
}


If you open the AcDbXrecord object associated with the key 'DWGPROPS' is a
resbuf structure, there are a number of defined DXF group codes associated with
the representation of Summary Information (layout of the AcDbXrecord). These
codes are as follows:

DXF Code    Meaning
1        "DWGPROPS COOKIE" - Do not edit
2        Title - Summary Tab
3        Subject - Summary Tab
4        Author - Summary Tab

6        Comments - Summary Tab         
7        Keywords - Summary Tab
8        Last saved by: - Statistics Tab
9        Revision no: - Statistics Tab

300        Name Value - Custom Tab. Thesse are saved as
to        strings in the format of "Name=Value"
309         
1 (repeated)    Hyperlink - Summary Tab

See Also:
Solution 30483: HOW TO EXTRACT THE DRAWING SUMMARY INFO USING LISP
Solution 32968: HOW TO ACCESS DRAWING PROPERTIES THROUGH AUTOMATION


See Also: SignPost Contents SignPost Index
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!

已领礼包: 1632个

财富等级: 堆金积玉

发表于 2013-5-1 15:14:51 | 显示全部楼层
很好的例子,支持
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

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

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-9-24 10:23 , Processed in 0.376464 second(s), 31 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表