- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have an input file that looks like the following:
I need to draw polylines between the points of the same group, the color of these lines is specified in the Line color column:
1- Blue
2-Red
3-Green
4-Yellow
So the output should look something like this (the numbers correspond to the # column, I have just shown them for reference they don't need to be part of the output):
This is obviously just an example the actual files I will use this script on are like 9,000 pts total. My start so far (not much just determining how many rows and how many groups, my plan was to do something in the second for loop but I was not sure what, perhaps an index match?):
Sub EqptLayout()
Dim acadApp As Object
Dim acadDoc As Object
Dim acadModelSpace As Object
Dim cl As Object
Dim i As Integer
Dim d As Integer
Dim excelApp As Object
Dim excelWorkbook As Object
Dim excelSheet As Object
Dim polyline As Object
Dim bearing As String
Dim foundation As String
Dim splice As String
Dim numRows As Integer
Dim startRow As Integer
Dim dblX As Double
Dim dblY As Double
Dim dblZ As Double
Dim dblRotation As Double
Dim utilObj As Object ' Late bound object
Set utilObj = ThisDrawing.Utility
' Start AutoCAD (if not already running)
On Error Resume Next
Set acadApp = GetObject(, "AutoCAD.Application")
On Error GoTo 0
If acadApp Is Nothing Then
Set acadApp = CreateObject("AutoCAD.Application")
acadApp.Visible = True
End If
Set acadDoc = acadApp.ActiveDocument
Set acadModelSpace = acadDoc.ModelSpace
Dim msg As String
i = 0
d = 0
Dim excelFilePath As String
excelFilePath = "C:\Users...\Test4.xlsx"
Set excelApp = CreateObject("Excel.Application")
Set excelWorkbook = excelApp.Workbooks.Open(excelFilePath)
Set excelSheet = excelWorkbook.Sheets(1)
With excelSheet
For Each cl In .Range(.[A1].CurrentRegion.Columns(1).Address) 'for each excel row
i = i + 1
Next cl
numRows = excelApp.worksheetfunction.Max(.Range("D1:D" & i))
startRow = excelApp.worksheetfunction.Min(.Range("D1:D" & i))
For d = startRow To numRows 'for each group
'perform line drawing here?
Next d
End With
End Sub
Any help is appreciated for how to approach this, thanks. Input file is attached.
Solved! Go to Solution.