×
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 Coordinates Into SolidWorks

Importing XYZ Coordinates Into SolidWorks

Importing XYZ Coordinates Into SolidWorks

(OP)
Hi

Does anyone know how to import points in XYZ format into Solid Works?

I am trying to generate a solid model of a transition duct using points, splines and the like. Currently my data is XYZ format in Excel.

Thanks!

-S

RE: Importing XYZ Coordinates Into SolidWorks

Start a new part and select form, the pull down menu, curve, curve through free points.

BBJT CSWP

RE: Importing XYZ Coordinates Into SolidWorks

Sorry that should read

Start a new part and select from, the pull down menu, curve, curve through free points.

BBJT CSWP

RE: Importing XYZ Coordinates Into SolidWorks

'copy and run this macro
'MAKE SURE OF THE FOLLOWING:
'all automatic contraints are OFF
'Zoom in to a very small area in your model in order to prevent merging of points
'source file is text file named "3dpoints.txt" in same directory as macro
'each line is a point coordinate in the format x    y    z[return] (you can save this from excel file
' ******************************************************************************
' 3DPoints.swb      8/3/99
'
' Edit a 3D sketch and run this macro to automate the creation of 3d points.
' Point data is in a TAB delimited file "3dpoints.txt"
' ex:   1.0 2.1 1
'       1.2 2.0 -1
'       ...
'
' Macro written by Joe Jones    joe@nhcad.com
' New Hampshire CAD             www.nhcad.com
'
' MECHANICAL DESIGN & CUSTOM PROGRAMMING
' ******************************************************************************

Dim swApp As Object
Dim modelDoc As Object
Dim retval As Object
Dim dataStr As String
Dim I As Integer
Dim Coords(1 To 3) As String
Dim Cnt As Integer
Dim Units As Integer
Dim Conversion As Double

Sub main()
    Set swApp = CreateObject("SldWorks.Application")
    Set modelDoc = swApp.ActiveDoc

    ' calculate conversion factor for meters --> current units
    Units = modelDoc.LengthUnit
    Select Case Units
    Case 0 ' mm
        Conversion = 1 / 1000
    Case 1 ' cm
        Conversion = 1 / 100
    Case 2 ' m
        Conversion = 1
    Case 3  ' in
        Conversion = 1 / 39.37
    Case 4, 5 ' ft and ft-in
        Conversion = 1 / 3.28
    End Select

    ' read data file
    Open "3dpoints.txt" For Input As #1

    Do While Not EOF(1)
        Cnt = 1
        Coords(1) = ""
        Coords(2) = ""
        Coords(3) = ""
        Line Input #1, dataStr
        For I = 1 To Len(dataStr)
            If Mid(dataStr, I, 1) = Chr(9) Then
                Cnt = Cnt + 1
            Else
                Coords(Cnt) = Coords(Cnt) + Mid(dataStr, I, 1)
            End If
        Next I

        Set retval = modelDoc.CreatePoint2(Val(Coords(1)) * Conversion, Val(Coords(2)) * Conversion, Val(Coords(3)) * Conversion)
    Loop
End Sub

On justice and on friendship, there is no price, but there are established credit limits.

RE: Importing XYZ Coordinates Into SolidWorks

oops the TGML messed up one of my notes:
format for coordinates is x[tab]y[tab]z[return]

source code derived from code downloaded from NHCad.com

On justice and on friendship, there is no price, but there are established credit limits.

RE: Importing XYZ Coordinates Into SolidWorks

(OP)
Thank You Very Much!

This will hopefully alleviate one of my headaches with creating this geometry.

-S

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