displaying point cloud data

Discussion in 'SolidWorks' started by paul, Nov 12, 2005.

  1. paul

    paul Guest

    Is any macro/utility/add-in available to read-in a large number of points
    (200K) into SW.

    I would appreciate any help.

    thanks


    Paul
     
    paul, Nov 12, 2005
    #1
  2. paul

    neil Guest

    see Shapeworks at http://www.baren-boym.com/
    if you scroll to the bottom of the page you will see they also have a
    conversion service for large point cloud files
    HTH
     
    neil, Nov 12, 2005
    #2
  3. paul

    cadguru Guest

    I wrote a point cloud utility a few years back that was hosted on the
    solidworks vb and macro library website. If you can't find it, e-mail me
    and I can find it and e-mail it to you.

     
    cadguru, Nov 14, 2005
    #3
  4. paul

    Tin Man Guest

    Did you try a search here first? About 10 threads down from this one
    there is a "POINT INPUT FROM EXCEL" thread that should get you started.

    Ken
     
    Tin Man, Nov 15, 2005
    #4
  5. paul

    cadguru Guest

    I wrote a Point cloud input Macro a long time ago that still works in 2006.
    It essentially reads in an xyz txt table and plots the points on the screen.
    The Cool thing about this one is that you can read in a huge number of
    points fairly quickly because of one simple line of code that allows the
    points to be added directly to the database instead of showing them on the
    screen one by one. I would recommend filtering out enough points to not
    exceed 150,000 points or so. This takes about 2 minutes to bring in on my
    machine. (Duall 64bit 3.6Ghz, 4Gb Ram Quadro FX3450)

    Make sure your point cloud data is in this format: And the filename is
    xyzpoints.txt.

    -21.894799 33.314639 30.003743
    -22.504399 33.345119 30.003743
    -23.037799 33.340039 30.003743
    -23.601679 33.223199 30.003743
    -24.104599 33.182559 30.003743
    -24.561799 33.248599 30.003743
    -24.998679 33.075879 30.003743
    -25.511759 33.065719 30.003743
    -25.933399 32.887919 30.003743
    -26.537919 32.715199 30.003743

    Open a new part then run the macro from tools - macro - run. The txt file
    needs to be in the same directory as the macro.

    If you want to plot less points then you can change the point plot step
    value in the script file from < 0 to something like < 10 and set the next
    lines step increment to 10 as well. This will only plot every 10th Point.

    Hope this helps you out.

    Copy the code below into a new text file and save it with the .swb file
    extension (pointcloud.swb) for instance. Then run the macro from within
    solidworks.

    -----START COPY FROM NEXT LINE-----
    ' 11/19/01 ALS: Developed and documented...Adam Smith Product Creation
    Studio Seattle, WA USA (206) 297-7200
    '
    ' This example will open and read a comma, space, or tab delimited datafile
    called xyzpoints.txt These
    ' points will then be used to generate a Point Cloud in a sketch of the
    currently open document.
    ' This program could also be modified to create a 3D spline using the
    InsertCurveFilePoint
    ' API function.
    '
    Public Sub Main()
    Dim XVal(175000), YVal(175000), ZVal(175000) As Double '
    Datapoints read from the datafile
    ' If hardcoded size unacceptable, use ReDim
    ' after determining number of lines in csv file.
    Dim numPts As Double ' Track the total #
    lines in the datafile
    'Dim numa As Double ' Variable for Stopping
    Short - Not Used
    'Dim numb As Double ' Variable 2 for
    Stopping Short - Not Used
    Dim Xvalc as Double ' Converted X Datapoint
    Dim Yvalc as Double ' Converted Y Datapoint
    Dim ZValc as Double ' Converted Z Datapoint
    Dim con As Double ' Variable to Store
    Conversion Factor
    Dim swApp As Object ' Variable to hold the
    SldWorks object
    Dim Model As Object ' Variable to hold the
    ModelDoc object
    Dim FileNum As Integer
    Dim activeSketch As Object

    FileNum = FreeFile ' Grab the next
    available file number

    con = .001 ' Set Conversion Factor
    Here

    Set swApp = CreateObject("SldWorks.Application") ' Attach to or open
    SolidWorks session
    Set Model = swApp.ActiveDoc ' Grab the current
    document
    If Model Is Nothing Then ' If no active doc found
    swApp.SendMsgToUser "No active doc found!" ' Warning to the user
    Exit Sub ' Exit this app
    End If

    Open "xyzpoints.txt" For Input As FileNum ' Optionally pop up dialog
    here to locate
    ' desired file.

    Do Until EOF(FileNum) ' Until EOF is reached
    numPts = numPts + 1 ' Keep track of line
    number
    Input #FileNum, XVal(numPts), YVal(numPts), ZVal(numPts) ' Read
    each line from datafile
    Loop

    Close #FileNum ' Close the datafile

    swapp.sendmsgtouser "File read"

    'numa = numPts - 10000 ' Number set for
    Stopping after X number of points

    'numb = numa - 200 ' Number set for
    Stopping after y + X number of points

    Set activeSketch = Model.GetActiveSketch
    if (activeSketch Is Nothing) then ' If a Sketch is not active, then

    swapp.sendmsgtouser "No Sketch created. One will be created for you"

    Model.Insert3DSketch ' insert a new sketch
    for our point cloud
    Model.SetAddToDB True ' Set to true allows
    data to be directly added to SW DB
    Model.SetDisplayWhenAdded False ' Set to False
    Deactivates display of data while plotting

    end if ' This will fail if this is not the 1st sketch

    'Do While numPts > numa
    Do While numPts > 0 ' For each data point
    down to specified number
    numPts = numPts - 1 ' Countdown from
    #Datapts by set number ie. plot every 5th point

    XValc = XVal(numPts + 1) * con ' Convert Meters to
    Units needed see con value above
    YValc = YVal(numPts + 1) * con ' Convert Meters to
    Units needed see con value above
    ZValc = ZVal(numPts + 1) * con ' Convert Meters to
    Units needed see con value above


    Model.createpoint2 XValc, YValc, ZValc ' Draw points

    loop

    swapp.sendmsgtouser "points plotted"

    Model.Insert3DSketch

    End Sub
    -----STOP COPY ON PREVIOUS LINE-----
     
    cadguru, Nov 15, 2005
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.