几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » ObjectARX(C++)
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


回复
 
主题工具 搜索本主题 显示模式
旧 2009-04-16, 05:14 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】[求助]获得cad当前活动图形的基本信息的大体思路?

[求助]获得cad当前活动图形的基本信息的大体思路?
[求助]获得cad当前活动图形的基本信息的大体思路?
如题。新手求助。。
我的问题是假如我在cad中画了一条线,那么我如何通过arx程序获得
它的图层,线性,颜色,线宽等基本信息呢?即如何从当前的块表记录获得
相关对象的objectid呢?
再扩展一下,假如是读取一个块对象的信息的话,如果用iterator来实现的话,那么
相关对象的类型判断如何解决呢?
只求一个思路(如解决办法,相关函数,变量等),谢谢! :-)
首先是你想怎样使用这条线的信息,如果仅仅是想显示出来,就看看这个
objectarx 4\samples\entity\multilinetooltipsamp\multilinetooltipsamp.vcproj
代码贴上来,让你看的眼花:
csampleipm::csampleipm(const bool storeindocvars, acapdocument* pdoc)
{
if (storeindocvars) {
assert(gdocvars.docdata(pdoc).m_pipm == null);
m_pdoc = pdoc;
m_pdoc->inputpointmanager()->addpointmonitor(this);
gdocvars.docdata().m_pipm = this;
} else
m_pdoc = null;
}
csampleipm::~csampleipm()
{
if (m_pdoc)
if (gdocvars.docdata(m_pdoc).m_pipm) {
m_pdoc->inputpointmanager()->removepointmonitor(this);
gdocvars.docdata(m_pdoc).m_pipm = null;
}
}
bool
csampleipm::excludefromosnapcalculation(const acarray<acdbobjectid>& nestedentity,
int gsselectionmark)
{
return false;
}
//
// this is where we take advantage of quite a bit of information
// provide by this big function to display multiline tooltip
// (new feature in acad 2) under the cursor aperture.
//
// it gets even more interesting when you mix it with osnap info.
//
// have fun!
//
acad::errorstatus
csampleipm::monitorinputpoint(
bool& bappendtotooltipstr,
char*& padditionaltooltipstring,
acgiviewportdraw* pdrawcontext,
acapdocument* pdocument,
bool pointcomputed,
int history,
const acgepoint3d& lastpoint,
const acgepoint3d& rawpoint,
const acgepoint3d& grippedpoint,
const acgepoint3d& cartesiansnappedpoint,
const acgepoint3d& osnappedpoint,
acdb:snapmask osnapmask,
const acarray<acdbcustomosnapmode*>& customosnapmodes,
acdb:snapmask osnapoverrides,
const acarray<acdbcustomosnapmode*>& customosnapoverrides,
const acarray<acdbobjectid>& apertureentities,
const acarray< acdbobjectidarray,
acarrayobjectcopyreallocator< acdbobjectidarray > >& nestedapertureentities,
const acarray<int>& gsselectionmark,
const acarray<acdbobjectid>& keypointentities,
const acarray< acdbobjectidarray,
acarrayobjectcopyreallocator< acdbobjectidarray > >& nestedkeypointentities,
const acarray<int>& keypointgsselectionmark,
const acarray<acgecurve3d*>& alignmentpaths,
const acgepoint3d& computedpoint,
const char* ptooltipstring)
{
char mtooltipstr[1024],
tempstr[100];
mtooltipstr[0] = '\0';
acad::errorstatus es;
acdbentity* pent;
acdbobjectid highlightid = acdbobjectid::knull;
if (pointcomputed)
{
//
// analyze the aperture entities.
//
if (apertureentities.length() > 0)
{
if(strlen(mtooltipstr) > 0)
strcpy(mtooltipstr, "\nentities under the cursor aperture:");
else
strcpy(mtooltipstr, "entities under the cursor aperture:");
for (int i = 0; i < apertureentities.length(); ++i)
{
if (acad::eok != (es = acdbopenacdbentity(pent, apertureentities[i], acdb::kforread)))
continue;
sprintf(tempstr, "\n %s%s%d%s", pent->isa()->name(), " <object id: ", pent->objectid(), ">");
strcat(mtooltipstr, tempstr);
pent->close();
// analyze the nested aperture entities.
acdbobjectidarray nestedids = nestedapertureentities[i];
int length = nestedids.length();
if (length > 1)
{
// there is a nested entitiy: get it.
acdbentity* pent2;
if (acad::eok == (es = acdbopenacdbentity(pent2, nestedids[length - 1], acdb::kforread))) {
sprintf(tempstr, "\n nested: %s", pent2->isa()->name());
strcat(mtooltipstr, tempstr);
pent2->close();
}
}
}
highlightid = apertureentities[0];
}
//
// analyze osnap.
//
if (history && acad::eosnapped)
{
char osnapinfo[500];
osnapinfo[0] = '\0';
switch (osnapmask)
{
case acdb::kosmaskend:
strcpy(osnapinfo, "\nosnap:\n end");
break;
case acdb::kosmaskmid:
strcpy(osnapinfo, "\nosnap:\n mid");
break;
case acdb::kosmaskcen:
strcpy(osnapinfo, "\nosnap:\n center");
break;
case acdb::kosmasknode:
strcpy(osnapinfo, "\nosnap:\n node");
break;
case acdb::kosmaskquad:
strcpy(osnapinfo, "\nosnap:\n quadrant");
break;
case acdb::kosmaskint:
strcpy(osnapinfo, "\nosnap:\n intersection");
break;
case acdb::kosmaskins:
strcpy(osnapinfo, "\nosnap:\n insert");
break;
case acdb::kosmaskperp:
strcpy(osnapinfo, "\nosnap:\n perpendicular");
break;
case acdb::kosmasktan:
strcpy(osnapinfo, "\nosnap:\n tangent");
break;
case acdb::kosmasknear:
strcpy(osnapinfo, "\nosnap:\n near");
break;
case acdb::kosmaskquick:
strcpy(osnapinfo, "\nosnap:\n quick");
break;
case acdb::kosmaskapint:
strcpy(osnapinfo, "\nosnap:\n apint");
break;
case acdb::kosmaskimmediate:
strcpy(osnapinfo, "\nosnap:\n immediate");
break;
case acdb::kosmaskallowtan:
strcpy(osnapinfo, "\nosnap:\n allowtan");
break;
case acdb::kosmaskdisableperp:
strcpy(osnapinfo, "\nosnap:\n disableperp");
break;
case acdb::kosmaskrelcartesian:
strcpy(osnapinfo, "\nosnap:\n relcartesian");
break;
case acdb::kosmaskrelpolar:
strcpy(osnapinfo, "\nosnap:\n relpolar");
break;
}
if (strlen(osnapinfo))
{
if (keypointentities.length())
{
strcat(osnapinfo, "\nkey entities:");
for (int i=0; i<keypointentities.length(); ++i)
{
if (acad::eok != (es = acdbopenacdbentity(pent, keypointentities[i], acdb::kforread)))
continue;
sprintf(tempstr, "\n %s", pent->isa()->name());
strcat(osnapinfo, tempstr);
pent->close();
}
}
}
strcat(mtooltipstr, osnapinfo);
}
}
//
// do highlighting, only the top level entity is highlighted.
//
static acdbobjectid oldhighlightid = acdbobjectid::knull;
if(highlightid != oldhighlightid)
{
if (acdbobjectid::knull != oldhighlightid)
{
es = acdbopenacdbentity(pent, oldhighlightid, acdb::kforread);
if (es == acad::eok)
{
es = pent->unhighlight();
pent->close();
oldhighlightid = acdbobjectid::knull;
}
}
es = acdbopenacdbentity(pent, highlightid, acdb::kforread);
if (es == acad::eok)
{
es = pent->highlight();
pent->close();
oldhighlightid = highlightid;
}
}
// turn on additional tooltip.
bappendtotooltipstr = true;
padditionaltooltipstring = mtooltipstr;
return acad::eok;
}
void mtooltipon()
{
if (!gdocvars.docdata().m_pipm)
new csampleipm;
}
void mtooltipoff()
{
if (gdocvars.docdata().m_pipm)
delete gdocvars.docdata().m_pipm;
}
// init this application. register your
// commands, reactors...
void initapplication()
{
acedregcmds->addcommand("asdk", "mtooptipon", "mton", acrx_cmd_modal, mtooltipon);
acedregcmds->addcommand("asdk", "mtooptipoff", "mtoff", acrx_cmd_modal, mtooltipoff);
acutprintf("\ncommands are: mtooptipon (mton) and mtooptipoff (mtoff).");
mtooltipon();
acutprintf("\nsample multiline tooltip is on.");
}
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭



所有的时间均为北京时间。 现在的时间是 04:05 PM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多