Error SET macro VBA Autocad

Error SET macro VBA Autocad

INKOIngenieria
Contributor Contributor
2,790 Views
11 Replies
Message 1 of 12

Error SET macro VBA Autocad

INKOIngenieria
Contributor
Contributor

 

running the application generates the error message when assigning the object variables.
Sometimes it works without error.
I appreciate any solution

 

 

0 Likes
Accepted solutions (1)
2,791 Views
11 Replies
Replies (11)
Message 2 of 12

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

which references have you added to your vba-project? Make sure the AutoCAD references are for the correct version of AutoCAD.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 3 of 12

INKOIngenieria
Contributor
Contributor

The version is acad 2020 and references to insert polyines and basic blocks are attached.

0 Likes
Message 4 of 12

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

>> references to insert polyines and basic blocks are attached

Can you show a screenshots of these references?

To try your code on other systems, can you create a small sample (with sample coordinates stored in your variable when creating the polyline) that fails on your system so we can try the exact same code on our workstations?

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 5 of 12

INKOIngenieria
Contributor
Contributor

HI,

This is the code used, with the variables assigned in an additional module
 

 

Option Explicit
Private Sub UserForm_Initialize()
    Txtx1.SetFocus
    Txtx1.SelStart = 0
    Txtx1.SelLength = Len(Txtx1.Text)
    MyArray = Array("1/4", "3/8", "1/2", "5/8", "3/4", "7/8", "1", "1 1/8", "1 1/4", "1 3/8")
    CBoxRefX.List = MyArray
    CBoxRefX.ListIndex = 2
    CBoxRefY.List = MyArray
    CBoxRefY.ListIndex = 1
 
End Sub
Private Sub CmdPoints_Click()
x1 = Val(Txtx1.Text)
npas = Val(Txtnpas.Text)
y1 = Val(Txty1.Text)
y2 = Val(Txty2.Text)
y3 = Val(Txty3.Text)
HT = Val(TxtHT.Text)
e1 = Val(Txte1.Text)
r1 = Val(Txtr1.Text)
s1 = Val(Txts1.Text)
s2 = Val(Txts2.Text)
b1 = Val(Txtb1.Text)
b2 = Val(Txtb2.Text)
hv = Val(Txthv.Text)
TipoESC = TxtTipoESC.Text
DetESC = TxtDetESC.Text
PDetESC1 = TxtPDetESC1.Text
PDetESC2 = TxtPDetESC2.Text
Corte1 = TxtCorte1.Text
Corte2 = TxtCorte2.Text
Corte3 = TxtCorte3.Text
PCorESC1 = TxtPCorESC1.Text
PCorESC2 = TxtPCorESC2.Text
    FrmStairs01.Hide
   
    Stairs01
   
    Unload FrmStairs01
   
End Sub
Private Sub CmdCancelar_Click()
    Unload Me
End Sub
Sub Stairs01()
prompt1 = vbCrLf & "Enter the start point of the stairs: " 'Mensaje 1
prompt2 = vbCrLf & "Enter the end point of the stairs: "  'Mensaje 2
prompt3 = vbCrLf & "Enter the point insertion: "  'Mensaje 3
startPnt = ThisDrawing.Utility.GetPoint(, prompt1)  'Punto inicial escalera
PtoIni = startPnt    'Punto final escalera
PntTxt1 = startPnt  'Punto texto
PtoRef1 = startPnt    'Puntos Refuerzo Escalera
PtoRef2 = startPnt
PtoRef3 = startPnt
PtoRef4 = startPnt
PtoRef5 = startPnt
PtoRef6 = startPnt
PtoRef7 = startPnt
PtoRef8 = startPnt
PtoRef9 = startPnt
PtoRef10 = startPnt
PtoRef11 = startPnt
PtoRef12 = startPnt
PtoRef13 = startPnt
PtoRef14 = startPnt
PtoRef15 = startPnt

endPnt = ThisDrawing.Utility.GetPoint(, prompt2)    'Punto final escalera
PtoFin = startPnt  'Punto final escalera
startPnt1 = ThisDrawing.Utility.GetPoint(, prompt3)  'Punto insercion escalera
PtoSta = startPnt1    'Punto Insercion escalera
xpto1 = startPnt(0) 'Punto inicial calculo distancia
xpto2 = endPnt(0)   'Punto final calculo distancia
DisTot = xpto2 - xpto1      'Distancia Total
x2 = (DisTot - x1) / npas   'Huella
nhue = (npas * 2) + 1
nchue = (npas * 2) + 2
h1 = HT / (nchue)
' Dibujar contorno y Pelda?os
alfarad = Atn(h1 / x2)
alfadeg = alfarad * 180 / (4 * Atn(1))
dr1 = r1 / Sin(alfarad)
hr1 = h1 - r1
xr1 = x2 * hr1 / h1
dr2 = (e1 - r1) / Sin(alfarad)
hr2 = h1 - e1 + r1
xr2 = x2 * hr2 / h1
dr3 = e1 / Sin(alfarad)
hr3 = h1 - e1
xr3 = x2 * hr3 / h1
dr4 = e1 / Cos(alfarad)
dr5 = (e1 - r1) / Cos(alfarad)
dr6 = r1 / Cos(alfarad)
dr7 = (dr5 - 0.04) / Tan(alfarad)
'dr8 = (dr7 + b2 - 0.04) * Tan(alfarad)
dr8 = (dr7 + b2 - 0.04) * (dr5 - 0.04) / dr7
dr9 = Round(2 * x2 / Cos(alfarad), 1)
dr10 = Round((3 * x2 + b2 - 0.04) / Cos(alfarad), 1)
dist1 = Sqr(((b1 + x1 - dr2 - xr2) - (0.04)) ^ 2 + ((e1 - r1) - (e1 - r1)) ^ 2)
dist2 = Sqr(((b1 + x1 + x2 * npas) - (b1 + x1 - dr2 - xr2)) ^ 2 + (-(h1 * (npas + 1) + dr5) - (-(e1 - r1))) ^ 2)
dist3 = Sqr(((b1 + x1 - dr1 - xr1) - (0.04)) ^ 2 + (-(r1) - (-(r1))) ^ 2)
dist4 = Sqr(((b1 + x1 + x2 * npas) - (b1 + x1 - dr1 - xr1)) ^ 2 + (-(h1 * (npas + 1) + dr6) - (-(r1))) ^ 2)
 
PtoRef1(0) = startPnt1(0) + 0.04: PtoRef1(1) = startPnt1(1) - r1: PtoRef1(2) = startPnt1(2)
PtoRef2(0) = startPnt1(0) + b1 + x1 - dr2 - xr1: PtoRef2(1) = startPnt1(1) - r1: PtoRef2(2) = startPnt1(2)
PtoRef3(0) = startPnt1(0) + b1 + x1 - dr1 - xr1: PtoRef3(1) = startPnt1(1) - r1: PtoRef3(2) = startPnt1(2)
PtoRef4(0) = startPnt1(0) + 0.04: PtoRef4(1) = startPnt1(1) - e1 + r1: PtoRef4(2) = startPnt1(2)
PtoRef5(0) = startPnt1(0) + b1 + x1 - dr2 - xr2: PtoRef5(1) = startPnt1(1) - e1 + r1: PtoRef5(2) = startPnt1(2)
PtoRef6(0) = startPnt1(0) + b1 + x1 - dr1 - xr2: PtoRef6(1) = startPnt1(1) - e1 + r1: PtoRef6(2) = startPnt1(2)
PtoRef7(0) = startPnt1(0) + b1 + x1 - dr1 - xr2 + dr9 * Cos(alfarad): PtoRef7(1) = startPnt1(1) - e1 + r1 - dr9 * Sin(alfarad): PtoRef7(2) = startPnt1(2)
PtoRef8(0) = startPnt1(0) + b1 + x1 + x2 * npas + b2 - 0.04 - dr10 * Cos(alfarad): PtoRef8(1) = startPnt1(1) - h1 * (npas + 1) - 0.04 - dr8 + (dr5 - dr6) + dr10 * Sin(alfarad): PtoRef8(2) = startPnt1(2)
PtoRef9(0) = startPnt1(0) + b1 + x1 + x2 * npas: PtoRef9(1) = startPnt1(1) - h1 * (npas + 1) - dr6: PtoRef9(2) = startPnt1(2)
PtoRef10(0) = startPnt1(0) + b1 + x1 + x2 * npas + b2 - 0.04: PtoRef10(1) = startPnt1(1) - h1 * (npas + 1) - 0.04 - dr8 + (dr5 - dr6): PtoRef10(2) = startPnt1(2)
PtoRef11(0) = startPnt1(0) + b1 + x1 + x2 * npas: PtoRef11(1) = startPnt1(1) - h1 * (npas + 1) - dr5: PtoRef11(2) = startPnt1(2)
PtoRef12(0) = startPnt1(0) + b1 + x1 + x2 * npas: PtoRef12(1) = startPnt1(1) - h1 * (npas + 1) - dr4: PtoRef12(2) = startPnt1(2)
PtoRef13(0) = startPnt1(0) + b1 + x1 + x2 * npas + b2 - 0.04: PtoRef13(1) = startPnt1(1) - h1 * (npas + 1) - dr8 - 0.04: PtoRef13(2) = startPnt1(2)
PtoRef14(0) = startPnt1(0) + b1 + x1 + x2 * npas - 0.05: PtoRef14(1) = startPnt1(1) - h1 * (npas + 1) - dr6 + 0.05 * Tan(alfarad): PtoRef14(2) = startPnt1(2)
PtoRef15(0) = startPnt1(0) + b1 + x1 + x2 * npas - 0.05: PtoRef15(1) = startPnt1(1) - h1 * (npas + 1) - dr5 + 0.05 * Tan(alfarad): PtoRef15(2) = startPnt1(2)

Long1 = Sqr((PtoRef5(0) - PtoRef4(0)) ^ 2 + (PtoRef5(1) - PtoRef4(1)) ^ 2)
Long2 = Sqr((PtoRef15(0) - PtoRef5(0)) ^ 2 + (PtoRef15(1) - PtoRef5(1)) ^ 2)
Long3 = Sqr((PtoRef2(0) - PtoRef1(0)) ^ 2 + (PtoRef2(1) - PtoRef1(1)) ^ 2)
Long4 = dr9
Long5 = Sqr((PtoRef14(0) - PtoRef8(0)) ^ 2 + (PtoRef14(1) - PtoRef8(1)) ^ 2)

PtoIni(0) = startPnt1(0): PtoIni(1) = startPnt1(1): PtoIni(2) = startPnt1(2)
PtoFin(0) = startPnt1(0) + b1 + x1: PtoFin(1) = startPnt1(1): PtoFin(2) = startPnt1(2)
ObjLayer = "VIGAS"
   
DrawLine
    For X = 1 To npas + 1
        PtoIni(0) = startPnt1(0) + b1 + x1 + x2 * (X - 1): PtoIni(1) = startPnt1(1) - h1 * (X - 1): PtoIni(2) = startPnt1(2)
        PtoFin(0) = startPnt1(0) + b1 + x1 + x2 * (X - 1): PtoFin(1) = startPnt1(1) - h1 * X: PtoFin(2) = startPnt1(2)
        DrawLine
    Next X
    For X = 1 To npas
        PtoIni(0) = startPnt1(0) + b1 + x1 + x2 * (X - 1): PtoIni(1) = startPnt1(1) - h1 * (X): PtoIni(2) = startPnt1(2)
        PtoFin(0) = startPnt1(0) + b1 + x1 + x2 * (X): PtoFin(1) = startPnt1(1) - h1 * X: PtoFin(2) = startPnt1(2)
        DrawLine
    Next X
Select Case (CBoxRefX.ListIndex)
Case (0): G90EstX = 0.1: G180EstX = 0.1: NBarraX = 2: txtNBarraX = "# 2 (1/4) 10 cm": visNBarra = "# 2 (1/4)"
Case (1): G90EstX = 0.15: G180EstX = 0.13: NBarraX = 3: txtNBarraX = "# 3 (3/8) 15 cm": visNBarra = "# 3 (3/8)"
Case (2): G90EstX = 0.2: G180EstX = 0.15: NBarraX = 4: txtNBarraX = "# 4 (1/2) 20 cm": visNBarra = "# 4 (1/2)"
Case (3): G90EstX = 0.25: G180EstX = 0.18: NBarraX = 5: txtNBarraX = "# 5 (5/8) 25 cm": visNBarra = "# 5 (5/8)"
Case (4): G90EstX = 0.3: G180EstX = 0.21: NBarraX = 6: txtNBarraX = "# 6 (3/4) 30 cm": visNBarra = "# 6 (3/4)"
Case (5): G90EstX = 0.35: G180EstX = 0.25: NBarraX = 7: txtNBarraX = "# 7 (7/8) 35 cm": visNBarra = "# 7 (7/8)"
Case (6): G90EstX = 0.4: G180EstX = 0.3: NBarraX = 8: txtNBarraX = "# 8 (1) 40 cm": visNBarra = "# 8 (1)"
Case (7): G90EstX = 0.5: G180EstX = 0.38: NBarraX = 9: txtNBarraX = "# 9 (1 1/8) 50 cm": visNBarra = "# 9 (1 1/8)"
Case (8): G90EstX = 0.55: G180EstX = 0.42: NBarraX = 10: txtNBarraX = "# 10 (1 1/4) 55cm": visNBarra = "# 10 (1 1/4)"
Case (9): G90EstX = 0.6: G180EstX = 0.46: NBarraX = 11: txtNBarraX = "# 11 (1 3/8) 60 cm": visNBarra = "# 11 (1 3/8)"
End Select
Select Case (CBoxRefY.ListIndex)
Case (0): G90EstY = 0.1: G180EstY = 0.1: NBarraY = 2: txtNBarraY = "# 2 (1/4) 10 cm": visNBarra = "# 2 (1/4)"
Case (1): G90EstY = 0.15: G180EstY = 0.13: NBarraY = 3: txtNBarraY = "# 3 (3/8) 15 cm": visNBarra = "# 3 (3/8)"
Case (2): G90EstY = 0.2: G180EstY = 0.15: NBarraY = 4: txtNBarraY = "# 4 (1/2) 20 cm": visNBarra = "# 4 (1/2)"
Case (3): G90EstY = 0.25: G180EstY = 0.18: NBarraY = 5: txtNBarraY = "# 5 (5/8) 25 cm": visNBarra = "# 5 (5/8)"
Case (4): G90EstY = 0.3: G180EstY = 0.21: NBarraY = 6: txtNBarraY = "# 6 (3/4) 30 cm": visNBarra = "# 6 (3/4)"
Case (5): G90EstY = 0.35: G180EstY = 0.25: NBarraY = 7: txtNBarraY = "# 7 (7/8) 35 cm": visNBarra = "# 7 (7/8)"
Case (6): G90EstY = 0.4: G180EstY = 0.3: NBarraY = 8: txtNBarraY = "# 8 (1) 40 cm": visNBarra = "# 8 (1)"
Case (7): G90EstY = 0.5: G180EstY = 0.38: NBarraY = 9: txtNBarraY = "# 9 (1 1/8) 50 cm": visNBarra = "# 9 (1 1/8)"
Case (8): G90EstY = 0.55: G180EstY = 0.42: NBarraY = 10: txtNBarraY = "# 10 (1 1/4) 55cm": visNBarra = "# 10 (1 1/4)"
Case (9): G90EstY = 0.6: G180EstY = 0.46: NBarraY = 11: txtNBarraY = "# 11 (1 3/8) 60 cm": visNBarra = "# 11 (1 3/8)"
End Select

PtoIni(0) = startPnt1(0) + b1 + x1 + x2 * npas: PtoIni(1) = startPnt1(1) - h1 * (npas + 1): PtoIni(2) = startPnt1(2)
PtoFin(0) = startPnt1(0) + b1 + x1 + x2 * npas + b2: PtoFin(1) = startPnt1(1) - h1 * (npas + 1): PtoFin(2) = startPnt1(2)
DrawLine
PtoIni(0) = startPnt1(0) + b1 + x1 + x2 * npas + b2: PtoIni(1) = startPnt1(1) - h1 * (npas + 1): PtoIni(2) = startPnt1(2)
PtoFin(0) = startPnt1(0) + b1 + x1 + x2 * npas + b2: PtoFin(1) = startPnt1(1) - h1 * (npas + 1) - 0.3: PtoFin(2) = startPnt1(2)
DrawLine
PtoIni(0) = startPnt1(0) + b1 + x1 + x2 * npas + b2: PtoIni(1) = startPnt1(1) - h1 * (npas + 1) - 0.3: PtoIni(2) = startPnt1(2)
PtoFin(0) = startPnt1(0) + b1 + x1 + x2 * npas: PtoFin(1) = startPnt1(1) - h1 * (npas + 1) - 0.3: PtoFin(2) = startPnt1(2)
DrawLine
PtoIni(0) = startPnt1(0) + b1 + x1 + x2 * npas: PtoIni(1) = startPnt1(1) - h1 * (npas + 1) - 0.3: PtoIni(2) = startPnt1(2)
PtoFin(0) = startPnt1(0) + b1 + x1 + x2 * npas: PtoFin(1) = startPnt1(1) - h1 * (npas + 1) - 0.3 + (0.3 - dr4): PtoFin(2) = startPnt1(2)
DrawLine
'dibujar contorno inferior escalera
PtoIni(0) = startPnt1(0): PtoIni(1) = startPnt1(1) - e1: PtoIni(2) = startPnt1(2)
PtoFin(0) = startPnt1(0) + b1 + x1 - dr3 - xr3: PtoFin(1) = startPnt1(1) - e1: PtoFin(2) = startPnt1(2)
DrawLine
PtoIni(0) = startPnt1(0) + b1 + x1 - dr3 - xr3: PtoIni(1) = startPnt1(1) - e1: PtoIni(2) = startPnt1(2)
PtoFin(0) = startPnt1(0) + b1 + x1 + x2 * npas: PtoFin(1) = startPnt1(1) - h1 * (npas + 1) - dr4: PtoFin(2) = startPnt1(2)
DrawLine
'dibujar lateral izq escalera
PtoIni(0) = startPnt1(0): PtoIni(1) = startPnt1(1): PtoIni(2) = startPnt1(2)
PtoFin(0) = startPnt1(0): PtoFin(1) = startPnt1(1) - e1: PtoFin(2) = startPnt1(2)
DrawLine
'dibujar hierro inferior
ObjLayer = "HIERRO"
PtoIni(0) = PtoRef4(0): PtoIni(1) = PtoRef4(1): PtoIni(2) = PtoRef4(2)
PtoFin(0) = PtoRef6(0): PtoFin(1) = PtoRef6(1): PtoFin(2) = PtoRef6(2)
DrawLine
PtoIni(0) = PtoRef2(0): PtoIni(1) = PtoRef2(1): PtoIni(2) = PtoRef2(2)
PtoFin(0) = PtoRef13(0): PtoFin(1) = PtoRef13(1): PtoFin(2) = PtoRef13(2)
DrawLine
'dibujar hierro superior
PtoIni(0) = PtoRef1(0): PtoIni(1) = PtoRef1(1): PtoIni(2) = PtoRef1(2)
PtoFin(0) = PtoRef2(0): PtoFin(1) = PtoRef2(1): PtoFin(2) = PtoRef2(2)
DrawLine
PtoIni(0) = PtoRef6(0): PtoIni(1) = PtoRef6(1): PtoIni(2) = PtoRef6(2)
PtoFin(0) = PtoRef7(0): PtoFin(1) = PtoRef7(1): PtoFin(2) = PtoRef7(2)
DrawLine
PtoIni(0) = PtoRef8(0): PtoIni(1) = PtoRef8(1): PtoIni(2) = PtoRef8(2)
PtoFin(0) = PtoRef10(0): PtoFin(1) = PtoRef10(1): PtoFin(2) = PtoRef10(2)
DrawLine
'dibujar muro lateral
ObjLayer = "MUROS"
PtoIni(0) = startPnt1(0): PtoIni(1) = startPnt1(1) + 0.2: PtoIni(2) = startPnt1(2)
PtoFin(0) = startPnt1(0): PtoFin(1) = startPnt1(1): PtoFin(2) = startPnt1(2)
DrawLine
PtoIni(0) = startPnt1(0) + b1: PtoIni(1) = startPnt1(1) + 0.2: PtoIni(2) = startPnt1(2)
PtoFin(0) = startPnt1(0) + b1: PtoFin(1) = startPnt1(1): PtoFin(2) = startPnt1(2)
DrawLine
PtoIni(0) = startPnt1(0): PtoIni(1) = startPnt1(1) - e1: PtoIni(2) = startPnt1(2)
PtoFin(0) = startPnt1(0): PtoFin(1) = startPnt1(1) - e1 - 0.2: PtoFin(2) = startPnt1(2)
DrawLine
PtoIni(0) = startPnt1(0) + b1: PtoIni(1) = startPnt1(1) - e1: PtoIni(2) = startPnt1(2)
PtoFin(0) = startPnt1(0) + b1: PtoFin(1) = startPnt1(1) - e1 - 0.2: PtoFin(2) = startPnt1(2)
DrawLine
'Dibujar linea corte X
ObjLayer = "ACHURADOS"
PntPo5(0) = startPnt1(0) - 0.05: PntPo5(1) = startPnt1(1) + 0.2
PntPo5(2) = startPnt1(0) + b1 / 2 - 0.024: PntPo5(3) = startPnt1(1) + 0.2
PntPo5(4) = startPnt1(0) + b1 / 2: PntPo5(5) = startPnt1(1) + 0.2 + 0.08
PntPo5(6) = startPnt1(0) + b1 / 2: PntPo5(7) = startPnt1(1) + 0.2 - 0.08
PntPo5(8) = startPnt1(0) + b1 / 2 + 0.024: PntPo5(9) = startPnt1(1) + 0.2
PntPo5(10) = startPnt1(0) + b1 + 0.05: PntPo5(11) = startPnt1(1) + 0.2
DrawPolyLine5
PntPo5(0) = startPnt1(0) - 0.05: PntPo5(1) = startPnt1(1) - e1 - 0.2
PntPo5(2) = startPnt1(0) + b1 / 2 - 0.024: PntPo5(3) = startPnt1(1) - e1 - 0.2
PntPo5(4) = startPnt1(0) + b1 / 2: PntPo5(5) = startPnt1(1) - e1 - 0.2 + 0.08
PntPo5(6) = startPnt1(0) + b1 / 2: PntPo5(7) = startPnt1(1) - e1 - 0.2 - 0.08
PntPo5(8) = startPnt1(0) + b1 / 2 + 0.024: PntPo5(9) = startPnt1(1) - e1 - 0.2
PntPo5(10) = startPnt1(0) + b1 + 0.05: PntPo5(11) = startPnt1(1) - e1 - 0.2
DrawPolyLine5

'Dibujar circulos barra X
nY = (Long1 + Long2) / s2
nY = Round(nY, 4)
nY = Int(nY)
PtoBlo(0) = PtoRef4(0): PtoBlo(1) = PtoRef4(1): PtoBlo(2) = PtoRef4(2)
Set InsertBlVar = ThisDrawing.ModelSpace.InsertBlock(PtoBlo, "Var2", 1, 1, 1, 0)
PtoBlo(0) = PtoRef15(0): PtoBlo(1) = PtoRef15(1): PtoBlo(2) = PtoRef15(2)
Set InsertBlVar = ThisDrawing.ModelSpace.InsertBlock(PtoBlo, "Var2", 1, 1, 1, 0)
s3 = Round((Long1 + Long2) / nY, 4)
If s3 > s2 Then
    nY = nY + 1
    s3 = (Long1 + Long2) / nY
Else
    s3 = s3
End If
   
If Round(s3, 4) > s2 Then
    nY = nY + 1
    s3 = (Long1 + Long2) / nY
Else
    s3 = s3
End If
n1 = (Long1) / s3
n1 = Int(n1)
For X = 1 To n1
    PtoBlo(0) = PtoRef4(0) + s3 * X: PtoBlo(1) = PtoRef4(1): PtoBlo(2) = PtoRef15(2)
    Set InsertBlVar = ThisDrawing.ModelSpace.InsertBlock(PtoBlo, "Var2", 1, 1, 1, 0)
Next X
 
End Sub
 
 
Variants
 
Public ObjLine As IAcadLine 'Objeto para crear Linea
Public AcadDoc  As Object 'Variables para crear linea
Public AcadModel As Object
Public Sep1 As Double    'Separacion estribos a dibujar
Public d1 As Double
Public d2 As Double
Public Sep2 As Double
Public Sep3 As Double
Public Sep4 As Double
Public L1 As Double
Public L2 As Double
Public PtoIni As Variant    'Puntos inicial y final dibujar linea
Public PtoFin As Variant
Public Spc1 As Double   'Espacio libre al dibujar estribos
Public ObjLayer As String   'Layer a asignar en elemento
 
 
 

 

f1.jpgf2.jpg

0 Likes
Message 6 of 12

grobnik
Collaborator
Collaborator

Hi  @INKOIngenieria 

I didn't read entire code but seems that you are "passing" variable from a Sub to another even if into the same module try to define variable as Global followed by variable declaration, so it will be available everywhere inside the project.

Let us know.

0 Likes
Message 7 of 12

INKOIngenieria
Contributor
Contributor

Hi.  grobnik

The variables were changed to global in another module and the error continues.
The variables were changed to global in the same module and the error continues.
 

 

f4.jpg

0 Likes
Message 8 of 12

grobnik
Collaborator
Collaborator

Hi @INKOIngenieria 

I tried this code inside an Excel sheet and it's working perfectly. I'm suggesting to check how the two arrays related to coord will be passed to Drawline Sub. This was the reasons because I told you to declare Global such variable. In addition PtoIni and PtoFin required 3poits X,Y,Z values. See Acad 2018 on line help at http://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-26C95029-14BB-40B9-9987-49EFC980CB9D

 

Finally you declared the two array coords PtoIni and PtoFin as Variant, shall be better to define As below code array 0 to 2 and double precision, then you have to write coords into PtoIni(0) as X, (1) as Y and (2) as Z, and the same for PtoFin

 

Option Explicit 'outside the Sub, into main module

Sub Drawline()
Dim AcadDoc As Object
Dim AcadModel As Object
Set AcadDoc = GetObject(, "Autocad.Application").ActiveDocument
Set AcadModel = AcadDoc.ModelSpace
Dim ObJline As AcadLine
Dim PtoIni(0 To 2) As Double
Dim PtoFin(0 To 2) As Double
PtoIni(0) = 5
PtoIni(1) = 10
PtoIni(2) = 0
PtoFin(0) = 20
PtoFin(1) = 30
PtoFin(2) = 0
Set ObJline = AcadModel.AddLine(PtoIni, PtoFin)
ObJline.Update
End Sub

 

 

 

0 Likes
Message 9 of 12

INKOIngenieria
Contributor
Contributor

Hi,  grobnik

 

The procedure is as follows:
1. In the form FrmStairs01 the required data is obtained
2. With the points x, y, z the sub drawline is called which is in the Mdlprocess module
3 All variables are defined in the MdlVariant module

At the moment of the message it is indicated "debug", then "continue (f5)" and the result is shown.
Detail is the message every time the macro is run.
 

F5.jpg

 
0 Likes
Message 10 of 12

grobnik
Collaborator
Collaborator

Hi @INKOIngenieria 

I'm very sorry of inconvenience, but there must be in any case something of wrong somewhere. The images you attached are too small for understanding the issue and read the message received.

I'm suggesting two options:

1) instead continue with F5 after debug try to use F8 (step by step) and verify if all variable value are correct by "adding to watch" it and check the value into watching windows. I don't know your skill with VBA debugging.

2) Share your Project with us (save as dvb project) so you will include the userform, and if there are some parameters  to set for a correct view of drawing results please indicate in a text file or only big picture of userform input data. I cannot promise you nothing and of course I'm aware from civil works.

 

I'm not seeing any other way to help you.

Bye

0 Likes
Message 11 of 12

INKOIngenieria
Contributor
Contributor

Hi  grobnik

attached the files

 

 

0 Likes
Message 12 of 12

grobnik
Collaborator
Collaborator
Accepted solution

Hi @INKOIngenieria I received and tested, the procedure doesn't hangs on my computer

for double check please see reference libraries attached and the results of drawing.

Of course I din't modify any parameter inside the form, and probably I settled point on screen not properly but the procedure doesn't hangs.

I'm using 64 bit Autocad 2019 Mechanical.

I really don't know how to help you.

Try to run on a different machine if you can.

grobnik_0-1590492175233.png

 

grobnik_1-1590492307549.png

 

 

0 Likes