![]() |
【转帖】[求助]获得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::osnapmask osnapmask, const acarray<acdbcustomosnapmode*>& customosnapmodes, acdb::osnapmask 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."); } |
| 所有的时间均为北京时间。 现在的时间是 01:19 PM. |