×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Importing XYZ Data into MDT5

Importing XYZ Data into MDT5

Importing XYZ Data into MDT5

(OP)
Does anyone know the best method to import XYZ Coordinate data into MDT5?
I have an Excel Spreadsheet with point data for an impellor. I wish to create a spline through these points.

RE: Importing XYZ Data into MDT5

Dear Fortyplus,

The following VBA code reads data from EXCEL and draws an spline in autocad.
You should keep open the excel document containing the data while running the macro. All data must start from address A1 in excel active sheet and X, Y, and Z coordinates for each fitpoint is read respectively from columns A, B, and C.
Copy and paste the following code into a module in AutoCAD VBA editor and save it under an arbitrary name. Then run the "Main" macro using the  "VBARUN" command.


Option Explicit
Option Base 0
Sub Main()
    Dim ex As Object
    Dim tt As Worksheet
    Dim I As Integer
    Dim J As Integer
    
    Set ex = GetObject(, "EXCEL.Application")
    Set tt = ex.ActiveSheet
    I = 0
    tt.Cells(1, 1).Activate
    Do While Not IsEmpty(ex.ActiveCell.Offset(I, 0))
        I = I + 1
    Loop
    I = I * 3 - 1
    Dim FitPoints() As Double
    ReDim FitPoints(I)
    I = (I - 1) / 3
    J = 0
    Do While J <= I
        FitPoints(0 + J * 3) = ex.ActiveCell.Offset(J, 0)
        FitPoints(1 + J * 3) = ex.ActiveCell.Offset(J, 1)
        FitPoints(2 + J * 3) = ex.ActiveCell.Offset(J, 2)
        J = J + 1
    Loop
    Dim startTan(2) As Double
    Dim endTan(2) As Double
    Dim SPLObj As AcadSpline
    startTan(0) = 1: startTan(1) = 0: startTan(2) = 0
    endTan(0) = 0: endTan(1) = -1: endTan(2) = 0
    Set SPLObj = ThisDrawing.ModelSpace.AddSpline(FitPoints, startTan, endTan)
    ZoomAll
End Sub

:)
Farzad

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources