23 Replies Latest reply on Sep 14, 2011 2:57 PM by Tom Grimm

    ASCII file of XYZ into SW?

    Bill Chernoff
      I have a set of data describing a delaunay triangulation.  Iwould like to get this data into Solidworks.  It looks likerandom-sized, joined 3d triangles, like a tiling, only withrandom triangles.  I can format the data any way I want. So if I could load a 3d sketch of each triangle, that wouldbe fine.  I could live with loading all the line segments. 

      If my ASCII data was a list like this:

      x1,y1z1,x2,y2,z2  
      x3,y3,z3, x4,y4,z4
      .
      .
      .
      how would I automatically draw a line from (x1,y1,z1) to(x2,y2,z2), etc


      Thanks for any suggestions.  I am not a total newbie with SW,but reading outside data files into SW is new.
         

        • ASCII file of XYZ into SW?
          Hi Bill
          Yes you can: INSRERT\CURVE\CURVE THRU XYZ POINTS
          • ASCII file of XYZ into SW?
            Charles Culp
            Well, now you've got me hooked.

            I've started working on a macro, I think I can get it to work.

            It's like an addiction!

            **Edit: I have added this post in the macro forum, to discuss some troubleshooting Ineed some help with.
              • ASCII file of XYZ into SW?
                Charles Culp
                Well, I was able to do it without much struggle.  Attached isa macro that should work well!

                Please, give it a shot and let me know if it works for what youneed.  Also, send the data file my way so I can give it atry!

                **Edit: And since I deleted my previous posts, I must mentionthat I used the macro created by Jim Sculley, and updated by MattLombard to create a 3D Point Cloud as the basis of my work. So they also deserve some credit for this!

                ** ReEdit: Adjusted per Jorn's reccomendations of usingthe "Split" function for parsing the text.  Alsoadded inches/metric conversion
                  • ASCII file of XYZ into SW?
                    Bill Chernoff
                    Charles:
                    Thanks!  I found the (minor) parsing error myself, and itworks now.  I will get real data posted today.  
                    I can already see the next problem which is stitching the trianglesinto a surface.  But first things first...
                    Thanks again.
                    Bill

                    • ASCII file of XYZ into SW?
                      Bill Chernoff
                      Hi Charles,
                      I have attached new data files.  They are imported into SW asline segments using your macro.

                      FYI:
                      The data is random points in x & y, with a function applied forthe z height.  The delaunay triangulation is applied in the xyplane.  I was going to set the world on fire with mysuper-duper graphing / surface fitting program, of which the DT waspart.  This was in 1988 (!) or so.  The program iswritten in DOS Turbo Pascal.  The data files go from the dospc to a 1.44 meg floppy to the downstairs computer which has both afloppy and USB, onto the USB memory stick, then back upstairs tothe computer which has SW on it.

                      Any ideas how to turn all the little triangles in to faces inSW?

                      Bill

                      PS ok  I can't seem to upload the files.  I'll post themon my web site.
                      www.star-techno.com/clsc/r150e.txt
                      www.star-techno.com/clsc/r1500e.txt
                      www.star-techno.com/clsc/r2000e.txt




                        • ASCII file of XYZ into SW?
                          Charles Culp
                          The website links you had in your post didn't work for me; thefiles didn't appear to be there at 12:54pm CST.

                          To upload a file to the forms click "Attach File(s)",then a dialog box will appear.  At the top is a button for"Browse..."  Find the file, then after exiting thefile dialog box, click on the "Upload File" button on thetop right of the upload dialog.  It will then show in thewhite listbox down below.  Click on the file in the white listbox, and click "attach file" to attach it to thispost. 

                          You should be able to fill the triangles using either the"planar surface" or "surface fill" commands,both of which are available in the Surfacing toolbar.  Theplanar surface may not work because of the way the sketch is setup, but the surface fill should work without problems (just moreprocessor intensive sometimes).

                          *On a separate note I never could figure out if planar surface orsurface fill was really faster for creating a flat surface. Maybe someone else knows if there is a difference (do I needto read "the" Bible?)
                            • ASCII file of XYZ into SW?
                              Mark Matthews
                              I believe that Planar surface is faster as this is just calculating a flat plane whose math to describe the face is basic. The Fill Surface is creating a higher order bounded surface which inherently has more data imbedded within it even if it is "flat".

                              Any triangle described by straight lines is planar.
                            • ASCII file of XYZ into SW?
                              Charles Culp
                              I got the files, Bill.  I guess it is not very easy to just"surface fill" between those lines; I thought it wouldjust work.

                              I do know what it will take to make the macro present the lines ina way that should work, so I will give that a try here soon. I have a rush project that needs my attention, but I shouldbe able to give this a look here in the near future.
                                • ASCII file of XYZ into SW?
                                  Bill Chernoff
                                  Hi Charles,
                                  I have been trying to "reply" but I have been havingtrouble with the forum and I have not been able to until now.

                                  I have noticed that if only one triangle is in the sketch, I canuse the "Filled Surface" command to get a surface, thenextrude it.  I have modified (very trial and error) the macroto load only 3 lines, then close the sketch and start a new one forthe next 3 lines.  Don't bother trying  that with thedata I posted, it is mearly a dump of all the lines in the DT, withno triangle association information.  I will have to re-outputthe lines from the triangle part of the database so the triangle's3 lines are outputted sequentially to include theline-connectedness info. 

                                  I tried to record a macro of this filled surface process, but thefilled surface part doesn't record.

                                  I have also noticed that If I insert a plane using the 3 points ofa triangle , then use that plane to sketch- really, traceover, the 3 lines, I can then use that sketch to use the"Planar Surface" command to get a filled triangle. The planar surface doesn't seem to work if I just pick linesfrom the 3dsketch.

                                  One more thing- if I extrude two adjacent triangles using 2adjacent 3dsketches, when I delete the one extrusion, the other isdeleted as well.

                                  I have been trying to get information/examples on the insertfillsurface2 command to try to automate the processbut have had no luck.  I think that would be key to thissubject.  The whole API subject is new to me.  Therequired parameter passing for the insertfillsurface2 isbeyond my level.

                                  Thanks again for your interest.
                                  Bill
                                    • ASCII file of XYZ into SW?
                                      Charles Culp
                                      Bill,
                                      I hope you didn't upgrade your Java plug-in!  I made thatmistake myself, stick with the old version.  The new onedoesn't work with this forum.

                                      If you can change your output, this would be prettystraightforward, I hope.  I can incorporate generating thesurfaces into the macro if the lines are "grouped" bythose that form triangles.  It would have to output all threeedges together, which means that most edges would be in thedata twice (one for each of the opposing triangles).

                                      If you want to do the process you were talking about by hand thereis a slightly easier technique.  Create a new 3d sketch, clickon three lines that make a triangle, click "convertentities" and close the sketch.  Then click on your new3d sketch, and do "fill surface".  This will createthe desired surface.

                                      I think I could tolerate doing it by hand for your 150e data,but the 1500 would drive me batty.

                                      I might be able to take a look at this tomorrow.
                                        • ASCII file of XYZ into SW?
                                          Bill Chernoff
                                          Playing with security settings and tech support calls and here Iam.

                                          I have produced new data files R150T.txt,  R1500T.txt, and R2000T.txt

                                          They are arranged as

                                          x1, y1, z1, x2, y2, z2, x3, y3, z3
                                          x1, y1, z1, x2, y2, z2, x3, y3, z3
                                          .
                                          .
                                          .
                                          -END-

                                          Each row has 1 triangle's xyz points.

                                          Well I'm still getting file upload problems "file is anillegal type"  so

                                          I'll put them on my web site again:
                                          www.star-techno.com/clsc/r150t.txt
                                          www.star-techno.com/clsc/r1500t.txt
                                          www.star-techno.com/clsc/r2000t.txt



                                            • ASCII file of XYZ into SW?
                                              Charles Culp
                                              That should work well, Bill!

                                              I got the files.  You can only upload image files(.gif/.jpg/.png/.bmp), or .zip files.  So if you want toattach them later, just .zip them first.  Plus, with .txtfiles it will compress them significantly.
                                                • ASCII file of XYZ into SW?
                                                  Ryan Foss
                                                  Because you can loft to a point, I find the best way to quickly create planar surfaces on point clouds is using a surface loft. You only need to make one 3d sketch line between two points and your are off and running. Use loft to create the planar surfaces. You can loft a line to a point, an edge to a point, and line to an edge, or a edge to an edge to create these surface triangles. I'll ususally just use the attached macro to bring in points and then use loft to traingulate them for small point clouds.

                                                  This was something I was doing for fun, see the attached 38 side object. I have an algorithm that places any number electrons on a sphere and they repel each other equally. I then import the points. 12 points would make an icosahedron. 20 verts made this object. I made a ton of these objects and loft was the fastest way to do it.

                                                  I guess I wonder why you are looking to triangulate point clouds in SW, seeing as there are quite a few packages out there really geared towards delauney triangulation of a point cloud, and then once you import a large polygon model into SW it becomes very heavy on the package because each triangle is essentially a bi-linear nurbs patch. Traditionally, polygon models have always been very heavy on SW, seeing as it is a feature based parametric nurbs modeler and not a RE solution. Surfacing this data can be quite cumbersome using insert curve through ref points. Scanto3d tried to accomplish this and does triangulation and surfacing but I feel this add-in has a long way to go.....especially after using Rapid Form, Raindrop Geomagic, Polyworks, and CopyCad.

                                                  I guess it was noted that this was for fun. I'm a longtime poster on other SW forums, but this topic sparked my interest so I thought I'd give my 2 cents.

                                                  Cheers
                                                    • ASCII file of XYZ into SW?
                                                      Charles Culp
                                                      Thanks for the input, Ryan.

                                                      Because of the number of faces in these models:



                                                      It would take too long to loft each triangulation by hand.  Ido like your idea of using the loft tool to make the planarsurface, however I think the macro is simpler to automate for thisone with filled surface.

                                                      Don't worry, I understand what happens to SolidWorks when modelsget too many surfaces.  The parts I normally work on can getto the point of bashing-head-into-keyboard slow; but it's what thecompany has, and I don't see them changing anytime soon.  Idon't know if Bill is in the same boat, but SW is all I have torender things in 3D, so I just want to do the most I can with whatI have!

                                                      If there is a way that SW could handle this large model better, Iwould definitely look at incorporating that into thismacro. 

                                                        • ASCII file of XYZ into SW?
                                                          Bill Chernoff
                                                          To fix the java issue:

                                                          Go to your user profile at the top of the page, select personal options, and then select the html editor instead of the wysiwyg editor. I talked to about 6 different people at solidworks and VAR over 3 days, and finally learned this from the company (fuzetalk) that supplies the forums software.

                                                          Charles, I sent a request to apisupport for a usage example of insertfillsurface2. We'll see if they can help.

                                                          Ryan, there is definatly a way to do this by hand, but I'd really like to automate the method so the surfaces are produced as the points are read from the file. Its just too tedious otherwise. To clarify, the points are already "delaunayed" when solidworks sees them. I'm not trying to do that in VB or anything like that!

                                                          I sure appreciate both your interest, and have felt bad these last few days when I couldn't reply due to the above issue. I will defineately post any further info I find on the insertfillsurface2 issue.

                                                          The attached files (thanks for the tip, Charles) are the same as I posted on my web site.

                                                            • ASCII file of XYZ into SW?
                                                              Ryan Foss
                                                              Bill and Charles,

                                                              I just wanted to mention the loft as another way to make a planar surface. I wouldn't want to loft 4000 points by hand. In the past I was working with point cloud data that consists of over 10 million points. You don't work with this kind of data in SW. I pulled the R2000T file into one of my RE packages and was able to quickly treat it as unordered data, triangulate it with delauney and voronoi diagram, fit some curves to the data, and surface it. The pics below are not perfect but it only took a minute. I would then bring this Final NURBS surface to SW and not even mess around with poly files in it. Going from Polys to Nurbs in SW is a pain in the butt (just tessalate a model in SW into stl and try and bring it back in), but since your poly counts in those files were pretty low, have you checked out Scanto3d add-in?

                                                              I took a look at your data at the end of the day here, and you don't need to mess around with creating a macro to surface this since it is already ordered. the first row of your data is a vector loop x1,y1,z1,x2,y2,z2,x3,y3,z3 if I am correct. You just need to write yourself something to put this data in .stl ASCII format and then import it into SW. Create yourself a little app or script to write out your vector loops in stl format:

                                                              solid Part1
                                                              facet normal 0.000000e+000 -1.000000e+000 0.000000e+000
                                                              outer loop
                                                              vertex x1 y1 z1
                                                              vertex x2 y2 z2
                                                              vertex x3 y3 z3
                                                              endloop
                                                              endfacet
                                                              facet normal 0.000000e+000 -1.000000e+000 0.000000e+000
                                                              outer loop
                                                              vertex x4 y4 z4
                                                              vertex x5 y5 z5
                                                              vertex x6 y6 z6
                                                              endloop
                                                              endfacet
                                                              endsolid

                                                              These vector loops will all import as triangle surfaces and you won't need to mess around with this surface fill macro stuff. Although, if you can create a macro charles I would be interested to see it.

                                                              You can also check out Accutrans (a free/cheap poly converter). It will read xyz vector loops and convert it into many polygon formats.

                                                              Regards,

                                                              Ryan
                                                                • ASCII file of XYZ into SW?
                                                                  Bill Chernoff
                                                                  Ryan, thanks for the info.
                                                                    • ASCII file of XYZ into SW?
                                                                      Bill Chernoff
                                                                      insertfillsurface2


                                                                      I sent the following to API support, and got a detailed response.
                                                                      See below.


                                                                      Date Opened : 5/30/2007 07:22:17 AM
                                                                      Summary : insertfillsurface2
                                                                      Description :
                                                                      Do you have an example of how to use insertfillsurface2 ? The parameter passing is a bit beyond me.

                                                                      I have a 3d sketch with 3 lines that form a triangle. I wouldlike to fill the triangle with a surface. The triangles come from a file. I can read in thenumbers and make the sketches - tons of triangles, but I can't automate the surface creation.

                                                                      Thanks in advance,
                                                                      Bill

                                                                      ********************* REPLY FOLLOWS ******************

                                                                      Dear Bill,

                                                                      See the below macro,


                                                                      Dim swApp As SldWorks.SldWorks
                                                                      Dim Part As ModelDoc2
                                                                      Dim SelMgr As SelectionMgr
                                                                      Dim Feature As Feature
                                                                      Dim featMgr As FeatureManager

                                                                      Sub main()

                                                                      Set swApp = Application.SldWorks
                                                                      Set Part = swApp.ActiveDoc
                                                                      Set SelMgr = Part.SelectionManager
                                                                      Set featMgr = Part.FeatureManager

                                                                      Dim edges(1) As Variant
                                                                      Dim faces(1) As Variant
                                                                      Dim edgeconstraints(1) As Variant
                                                                      Dim curveControl(1) As Long

                                                                      curveControl(0) = 1

                                                                      boolstatus = Part.Extension.SelectByID2("", "EDGE", 0.1861406461162, 0.09198854659419, 0.008724758200628, False, 0, Nothing, 0)
                                                                      Set edges(0) = SelMgr.GetSelectedObject6(1, -1)

                                                                      boolstatus = Part.Extension.SelectByID2("", "FACE", 0.1770067135628, 0.0837798642946, 0.01175586107098, False, 0, Nothing, 0)
                                                                      Set faces(0) = SelMgr.GetSelectedObject6(1, -1)

                                                                      boolstatus = Part.Extension.SelectByID2("Constraint Curve", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
                                                                      Set edgeconstraints(0) = SelMgr.GetSelectedObject6(1, -1)

                                                                      Set Feature = featMgr.InsertFillSurface2(1, swOptimizeSurface, edges, curveControl, faces, edgeconstraints)

                                                                      End Sub

                                                                      I hope this helps.

                                                                      Thanks,
                                                                      Pabitra

                                                                      Pabitra Behera | API Support
                                                                      www.solidworks.com | www.solidworks.com/api
                                                                        • ASCII file of XYZ into SW?
                                                                          Charles Culp
                                                                          Bill,

                                                                          Thanks for the information from API help.  I'm still stuck,maybe you have had better success yourself.

                                                                          I created a small macro to just do the surface fill, and was noteven successful with that. I have posted it in this thread for further review.  I suggest we discussany API questions over there, as some of the people who check thatforum regularly might be of help.
                                                                            • ASCII file of XYZ into SW?
                                                                              Charles Culp
                                                                              Bill,

                                                                              I got it to work, and create surfaces.  It does not use thesurface fill command.  It actually uses:swModel.InsertPlanarRefSurface

                                                                              This is the same as "planar surface".  In theFeatureManager, it will not recognize the 3d sketch as planar, forsome reason the macro does!  So I used that to myadvantage.

                                                                              It takes a little while to compute, I did your r150t.txt and ittook 2-3mins, so it might take a while for the larger ones (I havetwo 3.2GHz Xeon Dual Cores doing the computing, as well).

                                                                              Good Luck, and let me know if you have any problems!
                                                                                • ASCII file of XYZ into SW?
                                                                                  Bill Chernoff
                                                                                  Charles,

                                                                                  Thanks for your help. I can now do what I set out to do. For the smaller data sets, I can use the latest macro, and for the bigger ones, I can use the import ASCII STL option. Actually, if I present my data in this format, I can send it directly to my CAM program, and bypass Solidworks for this one.

                                                                                  Using yout latest macro, my computer also took about 2 minutes or so to do the r150t.txt data, but SW eventually hung on the R1500t.txt data.

                                                                                  Thanks again for your interest and invaluable help, both you and Ryan.

                                                                                  Bill
                                                                • Re: ASCII file of XYZ into SW?
                                                                  Charles Culp
                                                                  Attached is my code, but I'm also at a loss on how to useinsertfillsurface2 properly (it was just added).

                                                                  Maybe someone else with API experience can help.  We need VBAto reference the last created 3DSketch, and use the three linesdrawn in it to make a filled surface.

                                                                  I will poke around a little more and see if I can figure it out,but I'm rather stuck myself.

                                                                  I have attached a version of the macro that will read the newformatted input, and make each sketch into a separate 3DSketch.
                                                                    • Re: ASCII file of XYZ into SW?
                                                                      Tom Grimm

                                                                      Hello Charles

                                                                       

                                                                      My name is Tom Grimm.  I am a consulting product developer.  I have recently become aware of the DeLaunay Triangulation Algorithm implemented in 3D form.  I thought that I would explore the SW Knowledge Base to see if anyone knows of specific techniques in creating 3D forms with SW.  Your name comes up a lot!  I wonder if you might point me in a useful direction.

                                                                       

                                                                      Thanks in advance!

                                                                       

                                                                      Best Regards, Tom