Hello,
I've tried some code to move entities. For some reason, it removes the entities I want to delete, but it doesn't show them in the moved position. Here's the code:
With trans
If bool_had_program_info Then
Dim new_height As Double = dist + padding * 2.0
Dim height_difference As Double, height_threshold As Double
Dim block_name As String, class_block As clsTBlockComponent = Nothing
Dim cur_block_name_string As String
Dim blockRef As Autodesk.AutoCAD.DatabaseServices.BlockReference = well_name_blockRef
Dim id_list2 As New ObjectIdCollection
height_difference = new_height - old_height
height_threshold = well_name_blockRef.Position.Y
For Each blockRef In blockRef_list_copy
id_list2.Add(blockRef.Id)
Next
Dim drawables As List(Of Drawable) = CreateTransGraphics(trans, id_list2)
i = 0
For Each blockRef In blockRef_list_copy
For j = 0 To block_list.Count - 1
block_name = blockRef_list_name.Item(i)
class_block = SearchClassBlock(block_name, block_list)
Next
If (blockRef.Position.X = well_name_blockRef.Position.X) And (blockRef.Position.Y = well_name_blockRef.Position.Y) Then
Dim new_pt As New Autodesk.AutoCAD.Geometry.Point3d(blockRef.Position.X, blockRef.Position.Y + height_difference, 0)
block_name = blockRef_list_name.Item(i)
Dim id_list As New ObjectIdCollection
trans.GetObject(well_name_blockRef.Id, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForWrite)
well_name_blockRef.Erase()
id_list.Add(well_name_blockRef.Id)
MoveEntities(trans, blockRef.Position, new_pt, id_list)
' insertSubBlockReorder(new_pt, block_name, new_height, True, class_block, bt, trans, doc)
id_list.Clear()
ElseIf (blockRef.Position.Y >= height_threshold) Then
Dim new_pt As New Autodesk.AutoCAD.Geometry.Point3d(blockRef.Position.X, blockRef.Position.Y + height_difference, 0)
block_name = blockRef_list_name.Item(i)
Dim id_list As New ObjectIdCollection()
trans.GetObject(blockRef.Id, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForWrite)
blockRef.Erase()
id_list.Add(well_name_blockRef.Id)
MoveEntities(trans, blockRef.Position, new_pt, id_list)
' insertSubBlockReorder(new_pt, block_name, new_height, False, class_block, bt, trans, doc)
id_list.Clear()
Else
height_limit_sort_list.Add(i, blockRef)
End If
i = i + 1
Next
ClearTransGraphics(drawables)
trans.Commit()
trans.Dispose()
End If
End With
Private Function SearchClassBlock(str_block As String, cur_block_list As Generic.List(Of clsTBlockComponent)) As clsTBlockComponent
Dim cur_block As clsTBlockComponent
For Each cur_block In cur_block_list
If cur_block.BlockName = str_block Then
SearchClassBlock = cur_block
Exit Function
End If
SearchClassBlock = SearchClassBlock(str_block, cur_block.SubComponents)
Next
End Function
Private Sub UpdateTransGraphics(drawables As List(Of Drawable), curPt As Point3d, moveToPt As Point3d)
' Displace each of our drawables
Dim mat As Matrix3d = Matrix3d.Displacement(curPt.GetVectorTo(moveToPt))
' Update their graphics
For Each d As Drawable In drawables
Dim e As Entity = DirectCast(d, Entity)
e.TransformBy(mat)
TransientManager.CurrentTransientManager.UpdateTransient(d, New IntegerCollection())
Next
End Sub
Private Sub ClearTransGraphics(drawables As List(Of Drawable))
' Clear the transient graphics for our drawables
TransientManager.CurrentTransientManager.EraseTransients(TransientDrawingMode.DirectShortTerm, 128, New IntegerCollection())
For Each d As Drawable In drawables
d.Dispose()
Next
drawables.Clear()
End Sub
Thanks,
cannorth