Author Topic: Creation of STEP files via web interface  (Read 596 times)

0 Members and 1 Guest are viewing this topic.

labaneseren

  • Mosquito
  • Posts: 7
Creation of STEP files via web interface
« on: July 02, 2019, 05:58:40 AM »
I'm on the hunt for a Tool, preferably one that can be installed directly on my server, that will allow me to generate CAD files (eg. STEP) based on some parameters input by the user via the browser.
It's just like those sites where you can download a STEP file of bolts and nuts in all sizes. You input the length and size, and the step file is generated. I assume it is using some CAD generator on the server, that just inputs the parameters to a parametric model, which is then converted into a STEP or other formats.
an example is www.solidcomponents.com

Do any of you guys know of such a tool?
Or can I make it myself, using some kind of command based CAD generator?

I've been using CAD software for ages, but I've never had to go "below the surface" before.

Thanks so much!

dgorsman

  • Water Moccasin
  • Posts: 2394
Re: Creation of STEP files via web interface
« Reply #1 on: July 02, 2019, 03:54:06 PM »
I'm not entirely certain they generate such files.  Within a limited number of variables, it would be far easier to simply return a pre-made version.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

kdub

  • Mesozoic relic
  • SuperMod
  • Swamp Rat
  • Posts: 1367
  • class keyThumper<T>:ILazy<T>
Re: Creation of STEP files via web interface
« Reply #2 on: July 02, 2019, 04:58:43 PM »
From a quick look, they seem to be distributing pre-made files provided by manufacturers and/or distributors.

I know of no tool to do the job for you.
called Kerry in my other life

Sometimes the question is more important than the answer.
#ridesober

MickD

  • Gator
  • Posts: 3300
  • (x-in)->[process]->(y-out)
Re: Creation of STEP files via web interface
« Reply #3 on: July 02, 2019, 05:52:24 PM »
Most of the sites where you download model files would have each file pre-made, bolts for example come in say 5mm increments for length. A possible way to do this without CAD would be to have 'template' files where the user could enter the parameters and a server script adds this data to the template in the right places making the files somewhat parametric.

To create these files using a CAD engine you may need a special license as well as you are giving many people access to the app as a server when they are generally allowed only one user per seat.

Welcome to the Swamp!
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

labaneseren

  • Mosquito
  • Posts: 7
Re: Creation of STEP files via web interface
« Reply #4 on: July 03, 2019, 12:37:40 AM »
Hi all. Thanks for your replies.
I'm pretty sure the files are generated and not pre-made. The amount of variables can be quite large for some type of parts (eg. springs).
To see such kind of tool in action, check out this amazing site:
https://www.protiq.com/en/gear-configurator/
or
https://www.protiq.com/en/ics-cover-configurator/

I don't need real-time updated models like that, but it definitely shows that some CAD engine is at work.

MickD

  • Gator
  • Posts: 3300
  • (x-in)->[process]->(y-out)
Re: Creation of STEP files via web interface
« Reply #5 on: July 03, 2019, 12:48:02 AM »
Yes, I understand what you need but they are not using a CAD engine like AutoCAD et al, that is a custom built javascript/webgl engine that displays a simple 3d image of the part. This is basically the same as entering parameters into a template file but you get a visual output rendered using javascript as well.

If you wanted to develop your own 'engine' like the ones in the links it's not too hard, just takes time but in the end if you want to create a STEP file then you would need to take all the settings and create the file from scratch or use the template system (which would be a lot easier!).

hth
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

labaneseren

  • Mosquito
  • Posts: 7
Re: Creation of STEP files via web interface
« Reply #6 on: July 03, 2019, 04:18:41 PM »
Hi MickD. Thanks again.
It all sounds very good. Can you please give some concrete advice on where/how to actually start out. Since I'm new to CAD software I need some starting point.

I dont need a real time updated 3D image. Does that mean I dont need WebGL at all?

I "just" need to create a step file based on the set of parameters.
What tool can I use for creating step files? How do the "templates" you mention work? How do I make the interface to the web? (it looks like solidcomponents are using ASP.NET)

In other words: can you direct me to the right place to start reading up on these things? It looks like I have to learn this myself and get my hands dirty. Yay :)

MickD

  • Gator
  • Posts: 3300
  • (x-in)->[process]->(y-out)
Re: Creation of STEP files via web interface
« Reply #7 on: July 03, 2019, 06:00:19 PM »
It all depends on your programming experience but here's probably the best and easiest tech stack you can use:

You will need web hosting, I suggest a simple but reliable managed hosting service that provides cPanel with software installers that include Wordpress, Drupal and others. You can get a site up in minutes.

PHP (back end server) - not actually required but you will need someway to serve your files and perhaps only allow logged in users to access files etc. You can get a simple html canvas up and running to do the dev work but eventually you will need a host and file server anyway.

If you have no experience with PHP, use Wordpress with a webgl plugin or similar (basically a page to hold your 'canvas' to hold your image). -> https://wordpress.org/plugins/tags/webgl/
With a bit of work it wouldn't be too hard to create your own page anyway but that's an option to get going.

If you are comfortable with PHP and want total control then I highly recommend Laravel as your PHP framework, it's very mature with excellent doc's and support etc.

Javascript(JS) (client side) - you will be neck deep in JS from day one, I recommend you stay away from frameworks, most of your code will be plain JS anyway as it pertains to the drawing code not HTML DOM elements. I quite like the 'Module Pattern' to encapsulate my code. You can also use TypeScript but webgl examples are lacking so it may be harder to get going with, it's probably easier to learn than JS but it helps if you know JS to use it.

WebGL - There are many frameworks out there, some high level and some very low. I like three.js and there is probably more sample code using it than any other. Babylon looks good too, both of these are pretty low level. Take your time and check out a few, some have primitive objects ready to draw, some you need to build the primitives from scratch.

Templates
This could be done client side or server side, maybe if most of your code is JS then do it client side.
Basically I'd create a sample STEP (or whatever) file of the part you want in your usual CAD app, read carefully through it and note the variables that need to be changed/updated. You might be able to find a template library or build your own but basically you would edit the fields that need changing and give then a variable name. A real basic one would use search and replace, a real simple example below:

Your variables (in some file or hashtable/map of values):
Code - Python: [Select]
  1. width=200.0
  2. height=100.0
  3. length=1200.0

Your template:

Code - Python: [Select]
  1. blah bleh {{width}}, {{height}}, {{length}} foo bar baz and whatever other text in this template file.

You then do a search for "{{width}}" and replace it with the width value, rinse and repeat for each value.

You didn't mention your programming ability so this is a simple as it will get, if you have experience with web dev and other languages such as Python or Go then go for it but it takes a lot more work to set things up and look after them.

This isn't a small job, good luck! :)
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

labaneseren

  • Mosquito
  • Posts: 7
Re: Creation of STEP files via web interface
« Reply #8 on: July 04, 2019, 03:49:47 PM »
That got me started. Awesome.

I have a website, and I'm totally at home in PHP, but not so well versed in JS (yet). I've never done any web API jobs, so that one will be new for me. I've done programming in Joomla, which also uses an MVC structure. Laravel looks awesome, I'll give that a shot.

One question remains, though. Since I don't need 3D graphics in the browser, do I actually need WebGL?
It sounds like I can just use PHP and the magic of regular expressions to edit the STEP file code directly, and then create a "text" file with that content. If this is the case, I'm not going to need webGL and strictly speaking not even any JavaScript. Is that right?

MickD

  • Gator
  • Posts: 3300
  • (x-in)->[process]->(y-out)
Re: Creation of STEP files via web interface
« Reply #9 on: July 04, 2019, 07:14:23 PM »
That got me started. Awesome.

I have a website, and I'm totally at home in PHP, but not so well versed in JS (yet). I've never done any web API jobs, so that one will be new for me. I've done programming in Joomla, which also uses an MVC structure. Laravel looks awesome, I'll give that a shot.

Ah, good! I'm really liking Laravel as I have a project at the moment that requires a PHP setup. It's very mature and well thought out. Like all MVC frameworks, the folder structure sucks but you get used to it and I think this can be changed to suit.
Here's a free 'from scratch' course well worth looking at if you plan on using Laravel, the other course are also very good! https://laracasts.com/series/laravel-from-scratch-2018

You would only need an API for say javascript AJAX code really, they are no different than a normal call, the only difference is they send back JSON or some other data file to be consumed by the AJAX call client side or by another server (e.g. one server handles file serving (the html) and this server calls another server that hosts the database for the data then the file server packs it up and sends it in the html).

One question remains, though. Since I don't need 3D graphics in the browser, do I actually need WebGL?
It sounds like I can just use PHP and the magic of regular expressions to edit the STEP file code directly, and then create a "text" file with that content. If this is the case, I'm not going to need webGL and strictly speaking not even any JavaScript. Is that right?

Yep, that should be fine. I'd even try using the PHP template engine to work on the STEP file before rolling your own ;)
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

labaneseren

  • Mosquito
  • Posts: 7
Re: Creation of STEP files via web interface
« Reply #10 on: July 06, 2019, 08:48:25 AM »
Hi again.
I kind of got stranded when I started looking into how the STEP file is structured. It's definitely not very straightforward and easy to edit. The geometry I'm looking to create is kind of complex, even though it is quite simple to describe parametrically (spline sketches that are swept or extruded with twist).
I also had a look at the IGES format, which I think was slightly more human-friendly. Also, there is the lack of accessible documentation. Or maybe I haven't looked properly?

I feel I can go two directions at this moment:

1) Get a web hoster that supports FreeCAD and process it all through that. (CadQuery looks pretty nice for this purpose)

2) Hard code my IGES or STEP file using clever PHP scripts.
And the thing that comes to mind here, is that I can't possibly be the first to have wanted this? So maybe there already is some PHP code out there which can translate scripts into those formats? And if there isn't, it probably means it is too complex a task, so there must be other options.

MickD

  • Gator
  • Posts: 3300
  • (x-in)->[process]->(y-out)
Re: Creation of STEP files via web interface
« Reply #11 on: July 06, 2019, 08:06:42 PM »
What about DXF and STL? It's probably just as if not more common than STEP. I'd also look into IFC as BIM is getting built into more systems all the time.

Running a headless CAD app on a server won't be trivial to feed data and you need to either start the app every request or keep it running with a daemon or similar. Not to mention you will need to manage the hosting yourself (that means keeping the server OS and all server software up to date and maintenance) or pay a _lot_ extra for a managed setup.

While learning a file structure may seem daunting I think it would be a lot easier than setting up a CAD server, once you start to grok the file it will get a lot easier a lot quicker. I'd stick with a simple PHP script using regex for editing as you mentioned, it will be cheaper to build and easy to maintain.
For a test file, create a basic box or cylinder then work your way into more complicated files, I think once you work out where and how data is stored you'll be fine :)
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

labaneseren

  • Mosquito
  • Posts: 7
Re: Creation of STEP files via web interface
« Reply #12 on: July 08, 2019, 04:40:14 PM »
I'm now convinced coding the STEP file using PHP programming is the best option.
It's light on the server and requires no fancy application running all the time.

But I am pretty astounded by the lack of any guides or documentation on the internet explaining the commands for generating geometry in the STEP file format. This is a very very widely used format after all!
After days of searching, I finally stumbled upon this hidden gem, where at least the arguments of the functions are given.

I can always look through the STP files exported by my CAD software, to decode how they're made. But those files are generated automatically, and may not make use of the best/simplest available functions for a given geometry.

Then there are the many standards of the ISO 10303, available for purchase on ISO.org.
Did any of you ever have a look in them? Do they actually describe the functions? If they're any good in that respect, I'd be ready to buy them.