in een tekening heb ik een dynamisch blok staan met diverse variabelen.
lengte breedte om het voorlopig simple te houden.
nu wil ik deze gegevens aan een unieke nummer (pos nummer) hangen.
Ik heb de variabelen al in een constante gezet en kan ze ook op het scherm toveren dmv een msgbox.
nu wil ik het pos nummer blok inserten (dat lukt ook) maar nu wil ik de constante in de attributes van het pos nummer blok zetten om deze later naar excel te kunnen exporteren.
bij gevoegd heb ik een voorbeeld tekening met beide bloks er al in.
mijn code:
Public Tatts As Variant
Public Lengte
Pulic Breedte
Sub Getblockinsertpnt()
Dim Block As AcadBlockReference
Dim ReturnObj As AcadObject
Dim ReturnPnt As Variant
GetEnt: 'Start loop point
ThisDrawing.Utility.GetEntity ReturnObj, ReturnPnt, "Select a block: "
If ReturnObj.ObjectName <> "AcDbBlockReference" Then
MsgBox "The selected object wasn't a block!", vbExclamation
GoTo GetEnt 'Goto loop point
End If
Set Block = ReturnObj
'variabel
Variable = ReturnObj.GetDynamicBlockProperties
For I = LBound(Variable) To UBound(Variable)
'Check for variable and when found ask for input
If Variable(I).PropertyName = "Lengte" Then
Lengte = Variable(I).Value
End If
If Variable(I).PropertyName = "Breedte" Then
Breedte = Variable(I).Value
End If
Next I
MsgBox Lengte & " & " & Breedte
InsertBlock "G:\dynamic\Infpos_vc.dwg", 0
'Return the blocks insertion point
Insert_X = Block.InsertionPoint(0)
Insert_Y = Block.InsertionPoint(1)
Insert_Z = Block.InsertionPoint(2)
MsgBox "X: " & Insert_X & " ; Y:" & Insert_Y & " ; Z:" & Insert_Z
'GoTo GetEnt
End Sub
Private Sub InsertBlock1()
InsertBlock "G:\dynamic\Infpos_vc.dwg", 0
'Change the 0 to another value (in degrees) to rotate the block'
End Sub
Function InsertBlock(ByVal blockpath As String, ByVal rotation As Double)
Dim blockobj As AcadBlockReference
Dim insertionPnt As Variant
Dim prompt1 As String
'set rotation Angle
rotateAngle = rotation
rotateAngle = rotation * 3.141592 / 180#
'Prompt is used to show instructions in the command bar
prompt1 = vbCrLf & "Enter block insert point: "
ThisDrawing.ActiveSpace = acModelSpace
insertionPnt = ThisDrawing.Utility.GetPoint(, prompt1)
Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(insertionPnt, blockpath, 50#, 50#, 50#, rotateAngle)
'Change Modelspace into Paperspace to insert the block into Paperspace
Tatts("Lengte") = Lengte
Tatts("Breedte") = Breedte
End Function