Blocks update

Blocks update

Ray-Sync
Advocate Advocate
308 Views
1 Reply
Message 1 of 2

Blocks update

Ray-Sync
Advocate
Advocate

Hi. I have this code: 

Dim layerObj As AcadLayer
Dim b As AcadBlock
Dim L As AcadLine
Dim pt(1) As Variant
Dim s As Double, m As Double
Dim i As Byte
Dim PIL(0 To 2) As Double, PFL(0 To 2) As Double
Dim num As Integer
Dim k1 As String

Set layerObj = ThisDrawing.Layers.Add("Viguetas")
ThisDrawing.ActiveLayer = layerObj
layerObj.color = acMagenta

Me.Hide
pt(0) = ThisDrawing.Utility.GetPoint(, "Seleccione el punto inicial")
pt(1) = ThisDrawing.Utility.GetPoint(, "Seleccione el punto final")
Set L = ThisDrawing.ModelSpace.AddLine(pt(0), pt(1))

s = Me.TextBox1.Value: m = Me.TextBox2.Value

Randomize
num = Int((100 * Rnd) + 1)

k1 = "vigueta" & num

Set b = ThisDrawing.Blocks.Add(pt(0), k1)

i = 0
While s * i < L.Length

PIL(0) = pt(0)(0) + s * i * Cos(L.Angle): PIL(1) = pt(0)(1) + s * i * Sin(L.Angle)
PFL(0) = PIL(0) - m * Sin(L.Angle): PFL(1) = PIL(1) + m * Cos(L.Angle)

ThisDrawing.Blocks.Item(k1).AddLine PIL, PFL

i = i + 1
Wend

ThisDrawing.ModelSpace.InsertBlock pt(0), k1, 1, 1, 1, 0


L.Delete
Me.show

When I run my macro all it´s ok but i see my block after close my USERFORM. I would like to see my block before close my userform. When I create lines called "K" I type K.update then I can see lines before close my userform or when I create splines called "R" I type R.update then I can see my splines before close my userform. Can you help me to see my block before close my userform? 

jefferson
0 Likes
309 Views
1 Reply
Reply (1)
Message 2 of 2

Ray-Sync
Advocate
Advocate

This is the solution:

 Dim b As AcadBlock
    Dim L As AcadLine
    Dim pt(1) As Variant
    Dim s As Double, m As Double
    Dim i As Byte
    Dim PIL(0 To 2) As Double, PFL(0 To 2) As Double
    Dim num As Integer
    Dim k1 As String
    Dim Bl As AcadBlockReference
    
    Set layerObj = ThisDrawing.Layers.Add("Viguetas")
    ThisDrawing.ActiveLayer = layerObj
    layerObj.color = acMagenta
    
    Me.Hide
    pt(0) = ThisDrawing.Utility.GetPoint(, "Seleccione el punto inicial")
    pt(1) = ThisDrawing.Utility.GetPoint(, "Seleccione el punto final")
    Set L = ThisDrawing.ModelSpace.AddLine(pt(0), pt(1))
    
    s = Me.TextBox1.Value
    m = Me.TextBox2.Value
    
    Randomize
    num = Int((100 * Rnd) + 1)
    
    k1 = "vigueta" & num
    
    Set b = ThisDrawing.Blocks.Add(pt(0), k1)
    
    i = 0
    While s * i < L.Length
    
        PIL(0) = pt(0)(0) + s * i * Cos(L.Angle): PIL(1) = pt(0)(1) + s * i * Sin(L.Angle)
        PFL(0) = PIL(0) - m * Sin(L.Angle): PFL(1) = PIL(1) + m * Cos(L.Angle)
    
        ThisDrawing.Blocks.Item(k1).AddLine PIL, PFL
    
        i = i + 1
    Wend
    
    Set Bl = ThisDrawing.ModelSpace.InsertBlock(pt(0), k1, 1, 1, 1, 0)
    Bl.Update
    
    L.Delete
    Me.show
jefferson
0 Likes