.NET
cancel
Showing results forĀ 
ShowĀ Ā onlyĀ  | Search instead forĀ 
Did you mean:Ā 

Incorrect Entity IdMapping

0 REPLIES 0
Reply
Message 1 of 1
dalexanderSP3WJ
197 Views, 0 Replies

Incorrect Entity IdMapping

In the following code snippet, I am using the .SelectCrossingPolygon() method to select entities within a given area. With these selected entities I am using the .WblockCloneObjects() to copy the selected entities from the currentDocument to the newDocument. The actual cloning of the entities is working fine, I can see everything in the new document just fine. However after setting the IdMapping with the cloned entities of the previous document as a public property within my class, I cannot manipulate the entities that have been mapped.

I havent found too much documentation on how to manipulate entities once they have been cloned, can anyone point me in the right direction?

 

public void CopyObjectsInOffset(Document currentDoc, Document copyDoc, Point3dCollection offsetVerticies)
{
    Database currentDb = currentDoc.Database;
    Editor curDocEditor = currentDoc.Editor;

    ObjectIdCollection copyIds = new ObjectIdCollection();

    // Getting all the Object Id's from Crossing Polygon Selection
    PromptSelectionResult offsetSelRes = curDocEditor.SelectCrossingPolygon(offsetVerticies);
    SelectionSet objInOffsetSelect = offsetSelRes.Value;
    if (objInOffsetSelect != null)
    {
        foreach (SelectedObject obj in objInOffsetSelect)
        {
            copyIds.Add(obj.ObjectId);
        }
    }

    Application.DocumentManager.MdiActiveDocument = copyDoc;
    Database copyToDb = copyDoc.Database;

    using (DocumentLock copyLckDoc = copyDoc.LockDocument())
    {
        using (Transaction copyTrans = copyToDb.TransactionManager.StartTransaction())
        {
            BlockTable copyToBlkTbl = copyTrans.GetObject(copyToDb.BlockTableId, OpenMode.ForRead) as BlockTable;

            BlockTableRecord copyToBlkTblRec = (BlockTableRecord)copyTrans.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(copyToDb), OpenMode.ForRead);

            IdMapping copyToIdMap = new IdMapping();
            currentDb.WblockCloneObjects(copyIds, copyToBlkTblRec.ObjectId, copyToIdMap, DuplicateRecordCloning.Ignore, false);
            // Setting our copyToIdMap to a Class Property "OurIdMapping"
            OurIdMapping = copyToIdMap;

            copyTrans.Commit();
        }
    }
}


// In a different function that is being called after CopyObjectsInOffset()
foreach (ObjectId objId in oldDocumentIdCollection)
{
    ObjectId tempId = OurIdMapping.Lookup(lotNumId).Value;
    using (DBObject dbObj = trans.GetObject(tempId, OpenMode.ForWrite))
    {
        // Do things with DbObj
    }
}

 

A great thank you to anyone who can help! 

Labels (5)
0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


AutoCAD Beta