实际上,我刚刚更新了附件。
我需要应用来自每个嵌套所有者的转换…如果这有意义的话..也许代码会更好地解释它。
@Greg,它可能是在创建副本,但只是将它们放在lala land中。
- void copyNested( void )
- {
- Acad::ErrorStatus es;
- ads_name ssname = {0L,0L};
- ads_name adsName = {0L,0L};
- ads_matrix adsMatrix;
- resbuf *pbuf = NULL;
- ident_init(adsMatrix);
- if(HandleRtMsg(
- acedNEntSelP(_T("\nSelect Nested Entity: "),adsName,g_adsPoint,0,adsMatrix,&pbuf)) == RTNORM)
- {
- AcDbObjectId selectedEntId , selectedOwnerId;
- TRYRETVOID(acdbGetObjectId(selectedEntId,adsName));
- AcDbEntityPointer selectedEnt(selectedEntId,AcDb::kForRead);
- AcDbEntity *pNewEnt = static_cast(selectedEnt->clone());
- if (AcDbAttribute::cast (pNewEnt))
- { // based of Alexander Rivilis's code
- AcDbAttribute *pAtt = AcDbAttribute::cast (pNewEnt);
- AcDbText *pText = new AcDbText();
- pText->setPropertiesFrom(pAtt);
- pText->setHeight(pAtt->height ());
- pText->setWidthFactor(pAtt->widthFactor());
- pText->setHorizontalMode(pAtt->horizontalMode());
- pText->setTextStyle(pAtt->textStyle());
- pText->setVerticalMode(pAtt->verticalMode());
- pText->setTextString(pAtt->textStringConst());
- pText->setRotation(pAtt->rotation());
- pText->setPosition (pAtt->position());
- pText->setNormal(pAtt->normal());
- pText->setOblique(pAtt->oblique());
- pText->setThickness(pAtt->thickness());
- pText->setAlignmentPoint(pAtt->alignmentPoint());
- delete pNewEnt;
- pNewEnt = pText;
- }
- if(pbuf)
- {
- // --------------------- needed this ----------------------
- for(resbuf *ptmp = pbuf;ptmp!=NULL;ptmp=ptmp->rbnext)
- {
- es = HandleESMsg( acdbGetObjectId(selectedOwnerId,ptmp->resval.rlname) );
- if(es == eOk)
- {
- AcDbObjectPointer selectedOwner(selectedOwnerId,AcDb::kForRead);
- if(HandleESMsg(selectedOwner.openStatus()) == eOk)
- {
- TRYMSG(pNewEnt->transformBy(selectedOwner->blockTransform()));
- }
- }
- }
- acutRelRb(pbuf);
- }
- AcDbObjectId id;
- CTools::AddToCurrentSpace(id,pNewEnt);
- moveEnt(id);
- }
- }
|