Hi all
I want to make a macro that allows me to connect a certain number of points in them in a very specific way: I make 2D plans of stairs.
I currently import all the points (which are in an Excel* file with x y z coordinates) using a macro in a 2D sketch and I then connect the points by hand in order to redraw the staircase.
*excel file: 3 columns X Y Z
point A with point B
Point C with point D
Point A with Point C
Point B with Point D
Etc in order to draw each step.
not mastering VBA or very little, would some charitable souls come to my aid?
How I see it: I think you have to start in a 1st time to connect all the stair nosings, i.e. a pair of stitches:
a-b; c-d; e-f; etc
then connect each side of the step A-C; B-D etc
each staircase having a different number of steps, I must be able to enter a value in order to stop the macro at the end of X steps.
Each step is defined by 2 points
The rest of the points in the Excel file are used for landmarks outside the steps themselves, such as corners or wall returns, these points will be connected by hand...
The idea is to put this function in my excel file after the function that exports the points to solidworks
I think it's not very complex but I don't master programming. It's better to have one who knows than 10 who are looking as the other said...
Here! If you have any questions, I am at your disposal!
Here is the current code:
Private Sub btnTest_Click()
Dim swApp As SldWorks.SldWorks
Dim Part As ModelDoc2
Dim i as Integer
Set swApp = CreateObject("SldWorks.Application")
Set Part = swApp.ActiveDoc
If part is nothing then
MsgBox "Please activate a part document before using this macro."
Exit Sub
End If
If Part.GetType <> 1 Then
MsgBox "Please activate a part document before using this macro."
Exit Sub
End If
If Not Part.GetActiveSketch2 Is Nothing Then
MsgBox "Please exit the sketch before running this macro."
Exit Sub
End If
Part.ClearSelection2 True
Part.InsertSketch
Part.SetAddToDB True
i = 1
While Range("A" & i). Value <> ""
Part.CreatePoint2 Range("A" & i). Value / 100, Range("B" & i). Value / 100, 0
'Part.CreatePoint2 Range("A" & i). Value / 1000, Range("B" & i). Value / 1000, Range("C" & i). Value / 1000
i = i + 1
Wend
Part.SetAddToDB False
Part.ClearSelection
Part.InsertSketch
Part.ClearSelection2 True
End Sub
Thank you for your collaboration
Valley