Message 1 of 4

Not applicable
05-18-2020
11:25 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone,
I have this code that should create the same pattern as in the image. For some reason I get an error message here if I enter an even value at txtVloeren (the vertical integer). It seems that it only works with half of the odd numbers (3, 7, 11, 15, ...).
I don't know how to fix this. Could someone help me with this?
Thank you in advance.
Koo
pattern
Private Sub UserForm_Activate()
Dim Vloer As Integer 'horizontal integer
Dim Vak As Integer 'vertical integer
Dim i As Integer
Dim R As Integer
Dim C As Acad3DSolid
Dim P As AcadPoint
Dim pt1 As Variant
Dim pt2 As Variant
Dim pt As Variant
txtBreedteModules = 3
txtHoogteModules = 2
txtStartHoogte = 0.2
txtVloeren = 7
txtVakken = 5
cboRichting.AddItem "+X", 0
cboRichting.AddItem "+Y", 1
cboRichting.AddItem "-X", 2
cboRichting.AddItem "-Y", 3
cboRichting.ListIndex = 0
End Sub
Private Sub cmdC_Click()
Me.Hide
Dim strRichting As String
strRichting = cboRichting.Text
Vloer = 1
Vak = 1
i = 1
R = 150
pt = ThisDrawing.Utility.GetPoint(, "Selecteer linkeronderzijde van de gevel:")
Set P = ThisDrawing.ModelSpace.AddPoint(pt)
pt(2) = pt(2) + Val(txtStartHoogte.Text) * 1000
Set P = ThisDrawing.ModelSpace.AddPoint(pt)
pt1 = pt
pt2 = pt
Do Until Vak > Val(txtVakken.Text)
Do Until Vloer * 2 > Val(txtVloeren.Text)
If i Mod 2 = 1 Then
Set C = ThisDrawing.ModelSpace.AddSphere(pt1, R)
End If
pt1(2) = pt1(2) + Val(txtBreedteModules.Text) * 1000 * 2 'change Z
Vloer = Vloer + 1
i = i + 1
Loop
If Val(txtVloeren.Text) Mod 2 = 0 Then
i = i + 1
End If
pt1(2) = pt2(2)
If strRichting = "+X" Then
pt1(0) = pt2(0) + Val(txtBreedteModules.Text) * 1000 'change x
End If
If strRichting = "+Y" Then
pt1(1) = pt2(1) + Val(txtBreedteModules.Text) * 1000 'change y
End If
If strRichting = "-X" Then
pt1(0) = pt2(0) - Val(txtBreedteModules.Text) * 1000 'change x
End If
If strRichting = "-Y" Then
pt1(1) = pt2(1) - Val(txtBreedteModules.Text) * 1000 'change y
End If
pt2 = pt1
Vloer = 1
Vak = Vak + 1
Loop
End Sub
Solved! Go to Solution.