DYNAMIC Stretch in VBA

DYNAMIC Stretch in VBA

Anonymous
Not applicable
613 Views
5 Replies
Message 1 of 6

DYNAMIC Stretch in VBA

Anonymous
Not applicable
Im so fried.... If anyone knows what im doing wrong.. please slap me on the head and tell me...

Im just trying to modify an existing dynblk from a textbox in vba.

Private Sub CommandButton1_Click()
Dim Clientlogo As String
Clientlogo = TextBox1.Value & "#"
MsgBox Clientlogo
'Changes logo per Users Selections . .
Dim dybprop As Variant, i As Integer
Dim bobj As AcadEntity
For Each bobj In ThisDrawing.ModelSpace
If bobj.ObjectName = "AcDbBlockReference" Then
If bobj.IsDynamicBlock Then
If bobj.EffectiveName = "MONOPOLE" Then
dybprop = bobj.GetDynamicBlockProperties
For i = LBound(dybprop) To UBound(dybprop)
If dybprop(i).PropertyName = "BOTTOM" Then
dybprop(i).Value = Clientlogo
End If
Next i
End If
End If
End If
Next
Me.Hide
End Sub
0 Likes
614 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
dunno
you dont' seem to have any debug code in there to tell you what's going
on...
eg did you find a block....did it have the property....etc
is the block name capitalized? do you have Option Text Compare set?


wrote in message news:6029641@discussion.autodesk.com...
Im so fried.... If anyone knows what im doing wrong.. please slap me on the
head and tell me...

Im just trying to modify an existing dynblk from a textbox in vba.

Private Sub CommandButton1_Click()
Dim Clientlogo As String
Clientlogo = TextBox1.Value & "#"
MsgBox Clientlogo
'Changes logo per Users Selections
.
..
Dim dybprop As Variant, i As Integer
Dim bobj As AcadEntity
For Each bobj In ThisDrawing.ModelSpace


''' preferred to .ObjectName....
If TypeOf bobj Is AcadBlockReference Then

''' If bobj.ObjectName = "AcDbBlockReference" Then

If bobj.IsDynamicBlock Then
If bobj.EffectiveName = "MONOPOLE" Then
dybprop = bobj.GetDynamicBlockProperties
For i = LBound(dybprop) To UBound(dybprop)
If dybprop(i).PropertyName = "BOTTOM" Then
dybprop(i).Value = Clientlogo
End If
Next i
End If
End If
End If
Next
Me.Hide
End Sub
0 Likes
Message 3 of 6

Anonymous
Not applicable
Wow, Im new to this vba stuff. Do you know where I could find this information?
The Text Caps and names are correct. If i replace the 'clientlogo' with a number followed by a '#' it works fine. but the user needs to be able to type in the size of the sign. is there a way to do this?
0 Likes
Message 4 of 6

Anonymous
Not applicable
I dont know if this is correct or not, but it works. I changed the DIM..... as String to Double.

Now it works. Incase someone else needs the helping hand.


Dim dybprop As Variant, i As Integer
Dim bobj As AcadEntity
Dim Bottom As Double
Bottom = TextBox1.Text
For Each bobj In ThisDrawing.ModelSpace
If bobj.ObjectName = "AcDbBlockReference" Then
If bobj.IsDynamicBlock Then
If bobj.EffectiveName = "MONOPOLE" Then
dybprop = bobj.GetDynamicBlockProperties
For i = LBound(dybprop) To UBound(dybprop)
If dybprop(i).PropertyName = "BOTTOM" Then
dybprop(i).Value = Bottom
End If
Next i
End If
End If
End If
Next
0 Likes
Message 5 of 6

Anonymous
Not applicable
I dont know if this is correct or not, but it works. I changed the DIM..... as String to Double.

Now it works. Incase someone else needs the helping hand.


Dim dybprop As Variant, i As Integer
Dim bobj As AcadEntity
Dim Bottom As Double
Bottom = TextBox1.Text
For Each bobj In ThisDrawing.ModelSpace
If bobj.ObjectName = "AcDbBlockReference" Then
If bobj.IsDynamicBlock Then
If bobj.EffectiveName = "MONOPOLE" Then
dybprop = bobj.GetDynamicBlockProperties
For i = LBound(dybprop) To UBound(dybprop)
If dybprop(i).PropertyName = "BOTTOM" Then
dybprop(i).Value = Bottom
End If
Next i
End If
End If
End If
Next
0 Likes
Message 6 of 6

Anonymous
Not applicable
that will bomb as soon as someone enters a non numeric character into
textbox
Dim Bottom As Double
Bottom = TextBox1.Text

If IsNumeric(TextBox1.Text) Then
Bottom = cDbl(TextBox1.Text)'might as well make it explicit so its' clear in
your code what you're doing
Else
' Err.Raise BadEntry
End If
I know nothing about dynblock properties, when you create them you give them
a data type?
mark

wrote in message news:6030255@discussion.autodesk.com...
I dont know if this is correct or not, but it works. I changed the DIM.....
as String to Double.

Now it works. Incase someone else needs the helping hand.


Dim dybprop As Variant, i As Integer
Dim bobj As AcadEntity
Dim Bottom As Double
Bottom = TextBox1.Text
For Each bobj In ThisDrawing.ModelSpace
If bobj.ObjectName = "AcDbBlockReference" Then
If bobj.IsDynamicBlock Then
If bobj.EffectiveName = "MONOPOLE" Then
dybprop = bobj.GetDynamicBlockProperties
For i = LBound(dybprop) To UBound(dybprop)
If dybprop(i).PropertyName = "BOTTOM" Then
dybprop(i).Value = Bottom
End If
Next i
End If
End If
End If
Next
0 Likes