Author Topic: HELP! Clone NOD doesn't work.  (Read 1696 times)

0 Members and 1 Guest are viewing this topic.

tuankm

  • Guest
HELP! Clone NOD doesn't work.
« on: January 20, 2009, 08:35:22 PM »
Hi All,
I'm create a custom objects which it's style are stored in the NOD.
My custom objects have structure as followings:
class DLLIMPEXP KMTPIPELINE : public AcDbCurve {
protected:
static Adesk::UInt32 kCurrentVersionNumber ;
public:
...
AcDbHardPointerId : m_PipeTypeId;
.....
}
of which m_PipeTypeId is a custom object store in the AcDbdictionary which contain some property to draw the PipeLinew, with layout like this:

KMT_PIPE_TYPES
TYPE1
TYPE2
TYPE3
....
The pipe type custom object is contain some hard pointer inside.

My problem is when ever I copy my pipeline into other drawings (using ClipCopy, ClipPaste), if the destination drawing is not contain any KMT_PIPE_TYPES it work exactly as I want. But if the destination drawing already have the KMT_PIPE_TYPES in the dictionary it will add the dictionary with the name of *A1, *A2... and the pipe type is store in this NOD.
I have overidden the wblockconlone to resold this problem but it is not works.
Can anybody help?
My wblock clone is as followings:


Acad::ErrorStatus KMTPIPETYPE::wblockClone (AcRxObject *pOwnerObject, AcDbObject *&pClonedObject, AcDbIdMapping &idMap, Adesk::Boolean isPrimary) const {
//assertReadEnabled () ;
pClonedObject = NULL;
AcDbDatabase *pDest, *pOrig;
idMap.destDb(pDest);
idMap.origDb(pOrig);
if (pDest == pOrig)
return (AcDbObject::wblockClone (pOwnerObject, pClonedObject, idMap, isPrimary)) ;

bool isPrim = false;
if (isPrimary)
isPrim = true;

AcDbObjectId DestObjId;
// Get the style name in NOD in the dest dictionary,
// if exist return the dicId, if not return NULL

KMTArxUtils_GetDictionaryObjectId(DestObjId,m_Name,_T("KMT_PIPE_TYPES"),pDest);
if (!DestObjId){
KMTPIPETYPE *pClone = (KMTPIPETYPE*)isA()->create();
if (pClone != NULL)
pClonedObject = pClone;
else
return Acad::eOutOfMemory;
AcDbWblockCloneFiler filer;
dwgOut(&filer);
filer.seek(0L, AcDb::kSeekFromStart);
pClone->dwgIn(&filer);

DestObjId=KMTArxUtils_SaveToDict(_T("KMT_PIPE_TYPE"),pClone,pDest);
idMap.assign(AcDbIdPair(objectId(), DestObjId, Adesk::kTrue,
isPrim, (Adesk::Boolean)(pOwnerObject != NULL) ));

pClone->setAcDbObjectIdsInFlux();
AcDbObjectId id;
while (filer.getNextHardObject(id)) {

AcDbObject *pSubObject;
AcDbObject *pClonedSubObject;

if (id == NULL)
continue;

acdbOpenAcDbObject(pSubObject, id, AcDb::kForRead);
if (pSubObject->database() != database()) {
pSubObject->close();
continue;
}

pClonedSubObject = NULL;
if (pSubObject->ownerId() == objectId()) {
pSubObject->wblockClone(pClone,
pClonedSubObject,
idMap, Adesk::kFalse);
} else {
pSubObject->wblockClone(pClone->database(),
pClonedSubObject,
idMap, Adesk::kFalse);
}
pSubObject->close();

if (pClonedSubObject != NULL)
pClonedSubObject->close();
}
}
else{
idMap.assign(AcDbIdPair(objectId(), DestObjId, Adesk::kTrue,
isPrim, (Adesk::Boolean)(pOwnerObject != NULL) ));

}
return Acad::eOk;
}