void AsdkWblockReactor::otherWblock(AcDbDatabase* pDestDb, AcDbIdMapping& idMap, AcDbDatabase* pSrcDb) { AcDbBlockTable *pDestBlockTable; AcDbBlockTableRecord *pDestBTR; pDestDb->getSymbolTable(pDestBlockTable, AcDb::kForRead); pDestBlockTable->getAt(ACDB_MODEL_SPACE, pDestBTR, AcDb::kForRead); pDestBlockTable->close(); // Now pDestBTR is pointing to pSrcDb database's Model // Space not to the destination database's Model Space! // The code above is not correct! // END CODE APPEARING IN SDK DOCUMENT. acutPrintf("\nIncorrect destination BTR's ObjectId is \t\t%Ld", pDestBTR->objectId().asOldId()); pDestBTR->close(); AcDbBlockTable *pSrcBlockTable; AcDbObjectId srcModelSpaceId; pSrcDb->getSymbolTable(pSrcBlockTable, AcDb::kForRead); pSrcBlockTable->getAt(ACDB_MODEL_SPACE, srcModelSpaceId); pSrcBlockTable->close(); acutPrintf("\nSource Database's Model Space BTR's ObjectId is \t%Ld", srcModelSpaceId.asOldId()); }
// ----- AsdkSelectionFilterUI.SubentSel command (do not rename) static void AsdkSelectionFilterUI_SubentSel(void) { // we have to allow duplicates; otherwise, the xref would be selectable // only once (because the main entity is the one that counts). setAllowDuplicateSelection(curDoc(), true); ads_name sset, eName; AcDbObjectId id; // "_:n" gives us nested entities // if (RTNORM == acedSSGet("_:n", NULL, NULL, NULL, sset)) { acutPrintf("\n"); long len = 0; acedSSLength(sset, &len); for (long i = 0; i < len; i++)// For each entity in sset { resbuf *rb = NULL; // We use ssnamex() here, because the regular ssname() // would give only the main entity (the xref) // if (RTNORM == acedSSNameX(&rb, sset, i))//Get the sub entity { resbuf *rbWalk = rb; while (NULL != rbWalk) { if (RTENAME == rbWalk->restype) { eName[0] = rbWalk->resval.rlname[0]; eName[1] = rbWalk->resval.rlname[1]; if(Acad::eOk == acdbGetObjectId(id, eName)) { acutPrintf("Entity %d: <%x>", i, id.asOldId()); AcDbEntity *pEnt; if (Acad::eOk == acdbOpenObject(pEnt, id, AcDb::kForRead)) { acutPrintf("(%s)\n", pEnt->isA()->name()); pEnt->close(); } else acutPrintf("\nCouldn't open object"); } rbWalk = NULL; //force quit out of loop } else rbWalk = rbWalk->rbnext; } acutRelRb(rb); } } acedSSFree(sset); } setAllowDuplicateSelection(curDoc(), false); }
void AsdkWblockReactor::otherWblock(AcDbDatabase* pDestDb, AcDbIdMapping& idMap, AcDbDatabase* pSrcDb) { // To find the destination Model Space, you must look // it up in the ID map: AcDbBlockTable *pSrcBlockTable; pSrcDb->getSymbolTable(pSrcBlockTable, AcDb::kForRead); AcDbObjectId srcModelSpaceId; pSrcBlockTable->getAt(ACDB_MODEL_SPACE, srcModelSpaceId); pSrcBlockTable->close(); AcDbIdPair idPair; idPair.setKey(srcModelSpaceId); idMap.compute(idPair); AcDbBlockTableRecord *pDestBTR; acdbOpenAcDbObject((AcDbObject*&)pDestBTR, idPair.value(), AcDb::kForRead, Adesk::kTrue); // END CODE APPEARING IN SDK DOCUMENT. acutPrintf("\nCorrect destination BTR's ObjectId is:\t\t%Ld", pDestBTR->objectId().asOldId()); pDestBTR->close(); // Incorrect way done here so that the wrong value can be // compared to the correct value // AcDbBlockTable *pDestBlockTable; pDestDb->getSymbolTable(pDestBlockTable, AcDb::kForRead); pDestBlockTable->getAt(ACDB_MODEL_SPACE, pDestBTR, AcDb::kForRead); pDestBlockTable->close(); acutPrintf("\nIncorrect destination BTR's ObjectId is \t\t%Ld", pDestBTR->objectId().asOldId()); pDestBTR->close(); // source database Model Space BTR's ObjectId is shown to // demonstrate that this is what the incorrect method gets // pSrcDb->getSymbolTable(pSrcBlockTable, AcDb::kForRead); pSrcBlockTable->getAt(ACDB_MODEL_SPACE, srcModelSpaceId); pSrcBlockTable->close(); acutPrintf("\nSource Database's Model Space BTR's ObjectId is \t%Ld", srcModelSpaceId.asOldId()); }
void Jig3d::init(const AcDbObjectId& idEntity,const AcGePoint3d& refPoint,int viewportNumber) throw(CmdException) { m_int.m_idEntity = idEntity; m_refPoint = refPoint; AcGsManager * pMan = acgsGetGsManager(); if (pMan==NULL) throw CmdException("Cannot get Gs manager"); AcGsView * pView = acgsGetGsView (viewportNumber, false); if (pView==0) throw CmdException("Perform this command in a 3d View. Use the shademode command to activate one."); m_MSBObjectID = GetModelSpaceBlockID(); if (m_MSBObjectID.asOldId() == 0) throw CmdException("Unable to retrieve modelspace block ID"); m_pModel = pMan->getDBModel(); if (m_pModel==NULL) throw CmdException("Unable to retrieve AcDb AcGsModel"); m_pModel->onAdded (&m_int, m_MSBObjectID.asOldId()); m_mode = kMove; }
AcEdJig::DragStatus Jig3d::sampler() { setSpecialCursorType(AcEdJig::kRubberBand); AcGePoint3d pt; AcEdJig::DragStatus status; double angle; if (m_mode == kMove){ setKeywordList("Base X Y Z Exit"); status = acquirePoint(pt,m_refPoint); } else { setKeywordList("Exit"); //acquireAngle seems to have a defect //I'm applying the following temporary //workaround: status = acquirePoint(pt,m_refPoint); angle = acutAngle(asDblArray(pt),asDblArray(m_refPoint)); } if (pt == m_LastPoint) // if there is no work to be done, return status; // exit early! m_LastPoint = pt; if (status == AcEdJig::kNormal){ switch (m_mode) { case kMove: m_xformTemp = AcGeMatrix3d::translation(pt-m_refPoint); m_int.setTransform(m_xformTemp*m_xform); break; case kRotateX: m_xformTemp = AcGeMatrix3d::rotation(angle,AcGeVector3d::kXAxis,m_refPoint); m_int.setTransform(m_xformTemp*m_xform); break; case kRotateY: m_xformTemp = AcGeMatrix3d::rotation(angle,AcGeVector3d::kYAxis,m_refPoint); m_int.setTransform(m_xformTemp*m_xform); break; case kRotateZ: m_xformTemp = AcGeMatrix3d::rotation(angle,AcGeVector3d::kZAxis,m_refPoint); m_int.setTransform(m_xformTemp*m_xform); break; } m_pModel->onModified(&m_int, m_MSBObjectID.asOldId()); } return status; }
void CDlgReadInfo::OnBnClickedBtnSelect() { //交互选择实体 BeginEditorCommand(); CString strCadName; CComboBox* pCmb = (CComboBox*)GetDlgItem(IDC_COMBO_CADLY); pCmb->GetLBText(pCmb->GetCurSel(),strCadName); ads_name ssName; struct resbuf *filter=NULL; if(strCadName.CompareNoCase("所有图层") != 0) { filter=acutNewRb(AcDb::kDxfLayerName); filter->restype=AcDb::kDxfLayerName; filter->resval.rstring = (char*) malloc((strCadName.GetLength()+1)*sizeof(char)); strcpy(filter->resval.rstring,strCadName.GetBuffer(0)); filter->rbnext=NULL; } if (acedSSGet(":S", NULL, NULL, filter, ssName) != RTNORM) { acutPrintf("\n选择实体有误!"); acedSSFree(ssName); acutRelRb(filter); CompleteEditorCommand(); return; } if(filter != NULL) acutRelRb(filter); AcDbObjectId tempObjId; ads_name ssTemp; long nNum = 0; int nPos = 0; acedSSLength(ssName,&nNum); CString strSdeName,strId,strRowId; m_wndTree.DeleteAllItems(); // 清空属性列表 ResetListItems(); for(int i=0; i<nNum; i++) { acedSSName(ssName, i, ssTemp); if(Acad::eOk != acdbGetObjectId(tempObjId, ssTemp)) continue; strId.Format("%d",tempObjId.asOldId()); CDistXData tempXData(tempObjId,"ROWID_OBJS"); if(tempXData.Select("SDELYNAME",strSdeName)==FALSE) continue; if(tempXData.Select("OBJECTID",strRowId)==FALSE) continue; tempXData.Close(); HTREEITEM hItem = m_wndTree.InsertItem(strId); AcDbEntity *pEnt = NULL; if (Acad::eOk != acdbOpenObject(pEnt, tempObjId, AcDb::kForRead)) { return; } pEnt->close(); ITEM_DATA xxItemData; xxItemData.strID = strId; xxItemData.strSdelayerName = strSdeName; xxItemData.strCadLayerName = pEnt->layer(); xxItemData.strRowId = strRowId; mapItemData[strId] = xxItemData; nPos++; } acedSSFree(ssName); CompleteEditorCommand(); if (m_wndTree.GetCount() <= 0) { return; } HTREEITEM hItem = m_wndTree.GetFirstVisibleItem(); // 显示属性 OnSelectChanged(hItem); }