Message 1 of 11
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello
I'm trying to make a macro blocks outplacement
All blocks have a nested block named "Connection1".
I get the point of insertion of the "Connection1" block but with respect to the main block is not with respect to the drawing.
I leave codes and a drawing if anyone can help me
Thanks in advance
Private Sub btnRecoloca_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRecoloca.Click
Dim pto(2) As Double
pto = oACAD.Conexion
Dim pto1(2) As Double
pto1 = oACAD.Conexion
oACAD.MoverBloque("PRIMARIO ACS", pto1(0), pto1(1), pto(0), pto(1))
End Sub
Function Conexion() As Object
Dim oBloquePrincipal As Object
Dim oBloqueSeleccion As Object = Nothing
Dim oBloqueHijo As Object
Dim oBlkDefOut As AcadBlock
Dim Identificador As String
Identificador = "CONEXION1"
oApp.ActiveDocument.Utility.GetEntity(oBloqueSeleccion, "Select object:")
For Each oBloquePrincipal In oApp.ActiveDocument.Blocks
If oBloquePrincipal.name = oBloqueSeleccion.name Then
oBlkDefOut = oBloquePrincipal
For Each oBloqueHijo In oBlkDefOut
If TypeName(oBloqueHijo) = "IAcadBlockReference" Then
If oBloqueHijo.EffectiveName = Identificador Then
Return (oBloqueHijo.INSERTIONPOINT)
End If
End If
Next oBloqueHijo
End If
Next oBloquePrincipal
regenera()
End Function
Sub MoverBloque(ByVal strNombreBloque As String, ByVal point1x As Double, ByVal point1y As Double, ByVal point2x As Double, ByVal point2y As Double)
Dim oblockRef As AcadBlockReference
Dim oEnt As AcadEntity
Dim ptoInicio(2) As Double
Dim PtoFinal(2) As Double
ptoInicio(0) = point1x
ptoInicio(1) = point1y
ptoInicio(2) = 0
PtoFinal(0) = point2x
PtoFinal(1) = point2y
PtoFinal(2) = 0
For Each oEnt In oApp.ActiveDocument.ModelSpace
If TypeOf oEnt Is AcadBlockReference Then
oblockRef = oEnt
If oblockRef.EffectiveName = strNombreBloque Then
oblockRef.Move(ptoInicio, PtoFinal)
End If
End If
Next
End Sub
Solved! Go to Solution.