Problems :
I was trying copy objects using .clone or .copyfrom but i don't know how to copy objects without references between new and selected block.
My Code :
Dim acdoc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument Dim acCurDb As Database = acdoc.Database Dim acBt As BlockTable Dim acBtr As BlockTableRecord Dim E As Integer Dim newBtrId As ObjectId Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction acBt = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForWrite) acBtr = acTrans.GetObject(acBt(BlockTableRecord.ModelSpace), OpenMode.ForWrite) 'Let the user select Objects from drawing Dim acSSPrompt As PromptSelectionResult = acdoc.Editor.GetSelection() If acSSPrompt.Status = PromptStatus.OK Then Dim acSSet As SelectionSet = acSSPrompt.Value 'Paste position Dim myPoint As PromptPointResult = acdoc.Editor.GetPoint("Paste point: ") 'Read Selection Set For Each acSSObj As SelectedObject In acSSet 'Look for ObjectId of my Selected Object For Each acObjId As ObjectId In acBtr If acObjId = acSSObj.ObjectId Then 'Take selected object as Blockreference Dim Et As Entity = acTrans.GetObject(acObjId, OpenMode.ForWrite) If TypeOf Et Is BlockReference Then 'Current Block Selected Dim Br As BlockReference = Et 'Here I should Paste all objects from Br to BlkRef ... 'Create a new BlockTableRecord Dim blkRef As BlockTableRecord = New BlockTableRecord() blkRef.Name = "beta" & E + 1 'Add BlockTableRecord newBtrId = acBt.Add(blkRef) acTrans.AddNewlyCreatedDBObject(blkRef, True) 'Paint BlockReference Dim bob As New BlockReference(myPoint, newBtrId) acBtr.AppendEntity(bob) acTrans.AddNewlyCreatedDBObject(bob, True) E = E + 1 End If End If Next Next acTrans.Commit() End If End Using End Sub
Any idea will be apreciated !
Thank's a lot!
Solved! Go to Solution.
Solved by jeff. Go to Solution.
Hey Cheif and Paul,
Something I noticed and was having problems with was using DeepClone.
It seems DeepClone was just making a copy and the entities in the new BlockTableRecord and are pointing to same objects as the original,
so updating the entities the new BlockTableRecord or original will change both.
It looks like DeepCloneObjects is the correct way for cloning the entities.
Little more info in Link
http://www.theswamp.org/index.php?topic=39516.0
While dealing with ExplodeToOwnerSpace on a newer thread today, I did see in the ObjectARX help files that ExplodeToOwnerSpace does require the block to be uniformly scaled.
Hi,
this work fine for me.
I would like to redefine first level nested blocks without exploding main block.
I tried to use this code with the first level nested blocks object ids but it did not work.
Is this possible?
Thank you very much