SolidWorks does not work natively with mesh data (which is what STL files are). They can import them, but any tools are specifically for SW's native NURBS based data.
MeshLabs deals directly with mesh, and is free, and hosted on sorceforge. Rhino is a design software that works with native mesh data, but I don't know if it has any tools specifically for creating slices, and I would guess that it is not likely.
There are plenty of people who make homemade rapid prototyping machines, I would use Google and see what you can find. And try MeshLab.
Thanks, Charles. Meshlab got me confused. I tried to search for slicing tool but did not see it. I think i got the newest version 1.2.3.
Sorry, I didn't mean to insinuate that Meshlab would meet your needs. Only that it is free and worth a try. I have not tried to slice STL files with it before, it may not be able to.
see http://www.david-laserscanner.com/forum/viewtopic.php?f=7&t=529 for some clues in Meshlab and Rhino
BTW it has to be a closed body to slice in Meshlab
slice screenie.JPG 64.8 KB
I gave up! My model is a cylinder with honeycomb-like crosssections. You don't consider it an open body, do you? Everytime I tried to fill in the parameters for cross section planes and hit apply, Meshlab got crashed.
ok well Blender has a script that might work. See attach screenie of a plane intersecting a nested 'suzanne's with the resultant x section. I pulled it up so you could see it. BTW this also works for open meshes.
You can also make a filled surface which you could then extrude if you wanted....
I guess it could be modified to automate the process of moving the plane up an interval and repeating it for multiple slices - or additionally with extrudes.
I could probably change the script for you if I thought there was a larger application for it.
Afterwards you could export the outlines individually or together to dwg or 3d dxf by another script if you wanted to get the geometry into SW.
I think you can link scripts - have to check on that first. It might be a bit of work but if others could use it I would give it a go
What exactly are you trying to do? want to end up with?
Some experiments from script mods in progress...
My slow old pc for the internet with SW05 struggles with this.
Also of course SW opts out of serious import work if the file is big...
160 sections in Blender but it makes a lot of line segments in SW.
Ideally you want to export a dxf for each section and batch import to SW. Thats next...
EDIT: removed attach .py -see post below for new set
How to use:
This presupposes a little familiarity with Blender.
Use Blender 2.49b. Put the script in Blender>.blender>scripts
Set up a plane large enough to extend beyond the target mesh(es) in a starting position either intersecting them or very close to it.
The cutting will proceed normal to the plane in a positive direction so under them is a good place but it can be any angle.
Select the meshes to be x-sectioned with RMB and any others with shift RMB including lastly the cutting plane. Run the script. It will be under Scripts>Object>X-section at spacing.
In the popups select no fill, set the interval and the number of sections. If you are working to scale 1 BU = 1m
You can set say an interval of 0.1 and 10 off, and then run the script again and continue with a different 0.05 and 25 off if you wish , etc until you have enough x-sections.
In the 3d window you will see the plane moving up and making the x-sections as the script runs. Depending on complexity it can take a few seconds or perhaps 30.
When its done the Outliner will update to show all the x-sections as meshes with different numbers. If you have multiple meshes to cut you will end up with multiples of the number of sections set but at each level the outlines are grouped together so you can conveniently, with one selected, Select> Grouped>others in the same group, to get all if you wish.
Next you want to select just the xsection meshes you just made ( Select>Inverse can help here) and run the Script>Export>Autodesk dxf. This will make your 3d dxf for Dwgeditor or SW. Presently the xsections are all in one dxf unless you just select to to use other than them all. In the dxf script config set the layer name to be the object name.
BTW my Blender screen is a little different from the default but things ought to be recognisable
Next I will see if I can mod the dxf export...
BTW2 if you File>Import>STL you probably will want to select the mesh, 'Tab' into Edit mode and Mesh>Vertices>Remove Doubles, then 'Tab' out again, before running the scripts.
OK so here are 3 scripts. Its a bit of a hack but it seems to work
As before stick them in the .blender>scripts folder. This supposes you have the default Blender install in C:\Program Files.
The first one (appears as Scripts>Object>X-sections at spacing) ,as before, makes a cross section of a mesh a number of times at specified even intervals. Its kind of fun to watch these in action...
The second (appears as Scripts>Export>X-sections to DXF) will output a dxf file for each x section via another hacked script to a folder 'DXF output' on C:\. There is no UI for this bit but you can see messages in the blender console. With this DXF script it isnt necessary to select the xsections the script will find them as it goes.
If you have multiple meshes select and effectively join them ( Object>Join objects ) before you slice else the different sections at the same level will be saved separately.
My coding and hacking skills arent the best so no doubt it could be improved yet but its functional.
Beware that the DXF will over write existing ones in the folder if you repeat it, and that Windows will probably list the first xsection last cos it has no number.
If you only have say 20 sections you could import these manually to SW sketches on planes after that you need a macro I guess.
Hope this helps someone
(If you want all of the sections in the same DXF like the example in previous post select only, all the xsections and run the 'Autodesk DXF script that came with Blender 2.49.)
EDIT: Fixed issue and updated attach scripts. The second script now refers to a camera 'DXFprojection' which it creates at the origin that has the same direction as the cutting plane and as such is looking for a mesh called 'Plane' - ie call it that if it isnt already - in most cases it will be. You will notice its direction will update when you rerun the script if you have reorientated the plane. It is just a reference for the output program. Beware that slicing with a small spacing if the mesh is detailed can create a large Blender file. Blender imports many mesh formats so there are potentially many things you could slice and reproduce in SW - bits of anatomy and the like.
Just a note too about my usage of these xsections in SW - I found they were quite easy and quick to insert into a sketch after creating a bunch of planes, however constructing something with them was a pain mainly cos SW chokes and refuses with selections, fitting splines and constructing lofts.(already difficult connectors hate this density and you will hate them for it). Same if you try to bring in the whole lot in one 3d dxf. Particularly it chokes on say working with 50,000 line segments. There are also some minor errors here and there in the sliced geometry that mess things up to use them directly...
The best strategy I think is to pick the same SW planes and make another sketch on it with a spline with a few strategic points and use the imported sketch as a reference to match the shape. Hold down the ctrl key to prevent relations. With a min of well placed spline points, some spline handle refinement and some construction geometry everything can be smooth, symmetrical and flowing and it rebuilds etc quickly. Just hide or delete the imported sketches when you are done.
Update 1: the script now creates its own output folder 'DXF output' when it runs
Update 2: there was an issue if the blender file contained no camera at all to begin with.Sorry its a hack so its a little lean of error handling
Update 3: made ESC work for 'X-sections at spacing' script ,improved messages and the screen updates
Update 4: added point coords to text file option see post of 15/11/2010 for latest scripts
Help for possible gotchas are:
1. you forgot to select things before slicing = in the console says ERROR and has complaint about 'Mode' -> select your mesh and Plane and rerun
2. you deleted the DXFprojection camera after it was created for some reason = in the console complaint about ...no attribut 'RotX' -> save and reopen the blend to purge the persistant unused camera datablock and then rerun.
3. you wonder if its working -> with a heavy mesh (like 500,000 faces) it does take a bit of time, 5-10s or so, to make a section = be patient and monitor progress messages in console. In many cases processing is fairly fast and you can see progress of the plane in the 3d window and it stepping through the selection for export.
4. If you decide you made a mistake with your x-section parameters you can abort the script with the ESC key. This will stop making sections after it finishes the present one. The dxf export is quite rapid and should be ok without an ESC.
Bumping this thread in case anyone(?) downloaded the scripts and doesnt realise it was updated a couple of times.
Pity the guy who posted the question probably didnt hang around long enough to benefit from it. such is life...
Neil, I am really sorry. I was traveling last weekend and yesterday and today were the worst days of my life. I did not have time to have a look at your script yet. I really appreciate your time and please do not bump this post.
No worries. Glad you are out there somewhere.
I've updated the scripts again today to fix some small issues.
I found the script to produce quite accurate results.
Many of the meshes from cg world are a bit misshapen to begin with but ex CAD the geometry is sound.
I exported a SW model as vrml, brought it into Blender and exported to dxf, and brought those into SW sketches and they looked pretty good.
You could certainly use them to trace over for lofts profiles etc
So.... I've probably spent enough time on this hack now.
The scripts appear to work well enough for the purpose. Good luck.
Okay, I downloaded and set up Blender, it seems I will be okay following your detailed notes.
But let's start first with my model. I only need to slice my honeycomb because it has small cylinders at the transverse direction in addition to the longitudinal cylinders (see attached). After slicing the honeycomb, I will need the coordinates of each slices to be fed into a PLC. But slicing seems to only export the contours of the plance/slice, not the coordinates of the slice itself, or do I miss something here? My honeycomb is small, about 5mm diameter, 10 mm height, slice thickness about .3mm. Do you think it is doable?
1.jpg 94.9 KB
I hadnt expected something that small..
You dont want much do you.
I'll see if I can extract the point co-ords for each x-section to a text file...
haha, I do want much but it is not up to me to decide. By the way, that way you can only extract the coords of the points on the contours of each x-section, right? If we can only do that, that would only be suitable for subtractive machining, not additive.
Its time consuming but also I am a little confused about what it is you want.
Originally I was thinking of an application like reproducing a scanned human hand or face in SW with loft profiles.
Obviously this is a little different - actually its minute
What is it you are actually intending to do to make this? where does the stl originate? you seem to have a SW model already...
Usually you just send off a stl to a prototyping service and they take care of the layers for their machinery.
I dont think you will be able to reproduce the detail and accuracy of the part in the pic though.
I understood you wanted x-sections at various places with the coords of the points but you want it like sliced bread actually? or how??...
I allowed the settings to work 0.1mm to 10m spacing with 1-1000 xsections now seeing is how it is so small.
What is the ideal way you would like these x section coords presented then if you want them?
I could write each section to its own txt file.
It is the story of my life. Confuse people. Sorry about that.
I created the part in SW and imported the STL file. I am trying to build the part using addictive RP (home-made RP), meaning I would deposit building material at the solid areas of the part and leave out the holes on each individual layer. I brought the part to our machinist who has the VisualMill (I think) to see if he can convert the STL to slices with details for the toolpath as he could do it for CNC. But it would take him too long because CNC is subtractive (drill out the holes) instead of depositing a solid part as with additive RP.
How would you deposit material on top of each layer? I was thinking of having the deposit tool go 45-degree in a zig-zag pattern, so I would need the coords for the tool to move.
Now that I think about it, I don't really need a STL model, any kind would work as long as it gives me the coords of the toolpath for each layer.
I think it takes you too much time. I will ask around more how to do it. There are softwares that go with commercial RP machines but we don't have those. and it is expensive to buy one and it usually has more features than we need.
Thank you very much, Neil. I really appreciate your time.
Interesting project. If you dont mind me asking what is the part for?
Stl, vrml, obj 3ds, dae. its all potentially useable like this.
I now have the points being output as a text file for either each xsection or the whole item.
I dont think there is a specific order to them though. At least with dxf they are joined by lines to make a path
These can be read into SW as a 3d sketch via this macro http://solidworks.cad.de/mm_24.htm
I would think the macro could be adapted to batch load the individual sections.
Probably this still isnt what you want but I'm making something useful anyway (I hope)
attach is a pic of 5000 points from a slicing session of the Globalhawk.
This doesnt take very long to do at all.
I have some issues to work on yet (as you can tell the from the pic the xsections are out of line atm) but I'll post an update soon - for those who are still interested
5000points.JPG 179.1 KB
I don't mind but just can't. If my calculation is correct, I would need about 41,000 points and I have absolute no idea how to put that into my PLC (manual? ). Things get complicated, Neil, I am not familiar with macro in SW and also to DWGeditor (seems like AutoCad to me). Anyway, I've got a free software for another type of RP, it does slicing but there are weird lines between slices and still have problem extracting the coordinates. Have you heard about Fab@home?
Ok...not that important, just curious, its just surprisingly small...
No I hadnt heard of it but I found it with Google just now. Will have a read later.
Running a macro is very easy. With a SW part open - from the menu>Tools>macro>run. Navigate to the macro and open it.
You might have to change to .swp or .swb in the file type to see it.
A small UI opens up with this macro to select your file and the scale (delimiter = m ex Blender units) and then you hit go and a few seconds later you have your cloud of point in a 3d sketch. There is a sample text file with the macro download. If you close the sketch and run the macro again it makes another 3dsketch.
I tried a file of 18000 points ex one of my slicing experiments and its very quick and system lite. 41000 seems doable.
I am not sure if there is any limit on points in an individual sketch?, if there is hopefully its 64k although it might be 32k...
If the macro was made to be a batch loader then it would load each xsection into another 3d sketch with a more visually manageable number of points in each like a 1000. This would make it easy to hide the ones you dont to see while you create a path or profile from lines and splines.
You dont need to use the DWGeditor in this. Just slice your mesh and export either dxf or text files from Blender and open these in SW if you want to bring them in.
I am not sure how cnc machines would make use of this data but I presume you need to go via Mastercam or something simlar with step or iges?
Edit: found from Mastercam site:
Built-in data translators for IGES, Parasolid®, SAT (ACIS solids), AutoCAD® (DXF, DWG, and InventorTM files), SolidWorks®, Solid Edge®, KeyCreator®, Rhino®, STEP, EPS, CADL, STL, VDA, and ASCII.
Direct translators for CATIA®, Pro/E, and more are also available.
So dxf can be used...and stl - at least in this case..
It seems to me the only difference in milling and depositing is that there is like a glue gun on the end in place of a (stationary) cutter. Perhaps you would need to do a boolean or mirror to end up with the 'negative' part first?? have to think about that some more- and the path would be the same as say a roughing pass. you just have to change the tool length set to be shorter in increments of twice the cut depth advanced with each pass so it stays in air.(?)
dunno not my area. I have trouble just hacking scripts.
It is not really my area either. I am learning along with doing it. I'll try to talk to the CNC guy and a PLC guy again. We don't have mastercam but Gibbscam (just downloaded and installed it today, ); they should be the same.
Sorry for the delay - life got in the way.
Attach is an update of the scripts with some minor fixes and the point coord output.
This gives you the option of writing out the coords of the xsection points to a text file after the dxf sections have been done - either all together or a file for each section.
One thing to be aware of is that SW up axis is different from Blender up. The axes are consistant with the data in both but up is different.
I think though that machining has the same up as Blender (Z) ?
I should alter the SW macro so that batch loads any text files in a folder into separate sketches - but thats for another day.
I tried loading a couple of files including one of 77,000 pts into a single 3d sketch and it works ok.
Getting the cloud of 39,000 pts for the ferrai body into SW took about 6 mins all up from opening Blender,loading and sectioning the model, exporting the results and loading the textfile via macro into SW. I think actually later SW versions have a built in macro but not for batch loading - havent looked.
How useful this all is for your purpose I dont know.
btw I applied some rounding to the coords to 6 dec places out of Blender so that it produced sensible results cos there is some slight computational error that makes for example 0.4999999999 instead of 0.5 without it. The rounding is ok since the number its still accurate to a 1/1000 of a millimetre in SW. It seems fine anyway.
Thanks, Neil. Tough job you've done. I think I almost finished with my algorithm for my PLC to run for the part without holes on the transverse direction (all slices are the same). I am trying to figure out the way of generating the toolpath once we can extract the coords of the contours for each slice for the part with holes (just my thought, you don't need to do anything with it. )
Ok good luck with it.
I will probably see if I can make the batch loader just for my own entertainment - I havent played with SW api stuff before.
I thought too for anyone else wanting to use this I would post another screenie of Blender showing a way to enter the exact rot ,loc and scale of the selected object.
It also gives the bounding box dimension. These will help with positioning your target and cutting plane for the xsections.
It also shows the View Properties (open from the menu) where you can set the reference grid size.
Use the num pad 1,3,7 for ortho views (front, side ,top) -needs a User Preferences option see pic.
There is a small axes widget in the lower left of the 3d view to help you with orientation.
In the 3d view header change the manipulator from 'Global' to 'Normal' instead so that if you have a rotated Plane you can drag it normal to its face.
Add>Mesh>Plane from the top header menu will insert one at the 3d cursor.
Delete the cube by selecting it and either 'Delete' or 'X' key
Remember 1BU = 1metre in SW assuming you use the m units in the insert dxf and macro when you import. For your further reference the default cube in the 3d view when you install/open Blender for the first time is 2x2x2 BU.
Hope thats enough clues for people to follow. Blender 2.49b is a bit old and creaky I know .....unfortunately 2.5x isnt really ready yet and the python is somewhat different.
Alright, happy slicing. If you can, will you post your work here still? I hope that I can play some over Christmass when school is off. Just find out today that 40K points are too many for my PLC memory. LOL.
The only thing further I will be doing is dropping by to post the macro when/if I update it.
It might be a useful companion to the scripts for other users who need to reconstruct loft profiles from the x-section points.
Hope you get something worked out for your mission eventually.
I have a STL file to reverse engineer and SolidWorks will only load in graphically as it is to big.
So I have been looking for software that i can take slices through it and create curves to read in to SW.
Hence I came across this post.
If possible can you make the script for multi X sections available.
SW can get halfway there with the ScanTo3D add-in. It can automatically create curve sections through your mesh which result in 3D sketch splines. As far as geting the many coordinates of those splines, I don't know an automated way of doing that.
Untitled.jpg 592.6 KB
How about using existing (free/commercial) slicer to get one step further to g-code?
I'm using KISSlicer with my 3D printer. It's much better than the software that came with the printer....www.kisslicer.com
I need curves to generate surfaces/solid and then move on to design of mould tooling.