[CommandMethod("Test")]publicvoidTest(){try{//Code to copy block from another drawing to active drawingstringexternalFilePath=@"C:\Users\Ryzen2600x\source\repos\Template_AutoCAD_BasicApp_CSharp\CadApp\Sample.dwg";DatabasetempDatabase=newDatabase(false,true);tempDatabase.ReadDwgFile(externalFilePath,System.IO.FileShare.ReadWrite,true,"");ObjectIdCollectionblockObjectIdCollection=newObjectIdCollection();using(Transactiontransaction=tempDatabase.TransactionManager.StartTransaction()){BlockTableblockTable=transaction.GetObject(tempDatabase.BlockTableId,OpenMode.ForRead)asBlockTable;//Check if drawing contain specific blockif(blockTable.Has("Pole")){blockObjectIdCollection.Add(blockTable["Pole"]);}transaction.Commit();}if(blockObjectIdCollection.Count==0){return;}IdMappingidMapping=newIdMapping();ActiveUtil.Database.WblockCloneObjects(blockObjectIdCollection,ActiveUtil.Database.BlockTableId,idMapping,DuplicateRecordCloning.Ignore,false);//Code to loop through all block references and Copy Exiting referencesObjectIdCollectionblockRefObjectIdCollection=newObjectIdCollection();using(Transactiontransaction=tempDatabase.TransactionManager.StartTransaction()){BlockTableblockTable=transaction.GetObject(tempDatabase.BlockTableId,OpenMode.ForRead)asBlockTable;BlockTableRecordmodelSpaceBlockTable=transaction.GetObject(blockTable[BlockTableRecord.ModelSpace],OpenMode.ForRead)asBlockTableRecord;foreach(ObjectIdobjectIdinmodelSpaceBlockTable){if(objectId.ObjectClass.IsDerivedFrom(RXObject.GetClass(typeof(BlockReference)))){BlockReferenceblockReference=transaction.GetObject(objectId,OpenMode.ForRead)asBlockReference;if(blockReference.Name!="Pole"){continue;}//Create new Block Reference on Active Database//Copy Block Attribute values from original using(TransactionsubTransaction=ActiveUtil.Document.TransactionManager.StartTransaction()){//Open block table of active drawingBlockTableactiveblockTable=subTransaction.GetObject(ActiveUtil.Database.BlockTableId,OpenMode.ForRead)asBlockTable;//Opem Model Space block table for active drawingBlockTableRecordcurrentActiveSpaceBlockTableRecord=subTransaction.GetObject(ActiveUtil.Database.CurrentSpaceId,OpenMode.ForWrite)asBlockTableRecord;if(!activeblockTable.Has("Pole")){return;}//Get Access to block definationBlockTableRecordactiveBlockTableRecord=subTransaction.GetObject(activeblockTable["Pole"],OpenMode.ForRead)asBlockTableRecord;//Create new Block referenceBlockReferencenewBlockReference=newBlockReference(blockReference.Position,activeBlockTableRecord.ObjectId);//Add block reference to active spacecurrentActiveSpaceBlockTableRecord.AppendEntity(newBlockReference);//Add blockReference to current transactionsubTransaction.AddNewlyCreatedDBObject(newBlockReference,true);//Iterate block definition to find all non-constant AttributeDefinitionsforeach(ObjectIdidinactiveBlockTableRecord){AttributeDefinitionattDef=subTransaction.GetObject(id,OpenMode.ForRead)asAttributeDefinition;if((attDef!=null)&&(!attDef.Constant)){using(AttributeReferenceattRef=newAttributeReference()){attRef.SetAttributeFromBlock(attDef,newBlockReference.BlockTransform);attRef.TextString=attDef.TextString;//Add the AttributeReference to the BlockReferencenewBlockReference.AttributeCollection.AppendAttribute(attRef);subTransaction.AddNewlyCreatedDBObject(attRef,true);}}}subTransaction.Commit();}}}transaction.Commit();}tempDatabase.Dispose();}catch(System.Exceptionex){Application.ShowAlertDialog($"Something went wrong error:{ex.Message}");}}