Generate OpenSCAD models from AngelScript

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Generate OpenSCAD models from AngelScript

cacb
Hi,

I hope I am not breaking any rules by posting this, if you believe I am
just say so and I will go away :-)

In another thread I recently mentioned that I am experimenting with
AngelScript for creating CSG models, using OpenSCAD as the "back end"
via its .csg file format.

(I said I would write about it on my blog when there was anything new,
but due to technical problems I cannot access it at the moment, so
instead this message)

I have done quite a bit the last couple of days and I believe have some
decent results. As an example, this rotate sweep was done without the
upcoming rotate_extrude in OpenSCAD:

http://arnholm.org/software/as_csg/test_sweep_rotate.png

This is the AngelScript CSG code to produce the above:

#include "lib_sweep.as"    // provides general sweep features
#include "lib_degrees.as"  // provides deg/rad conversions

shape@ main_shape()
{
    // specify a rotation sweep of a circle profile
    double s_rad  = 100;           // sweep radius
    double s_ang  = to_rad(120);   // sweep angle=120deg
    uint   s_nseg = 60;            // sweep #segments
    double c_rad  = 30;            // circle radius
    shape2d@ xsec = circle(c_rad); // sweep profile

    // use path_rotate for the sweep
    return sweep(path_rotate(xsec,s_rad,s_ang,s_nseg));
}

void main()
{
    shape@ obj = main_shape();
    obj.write_csg(GetOutputFullPath('.csg'));
}


The sweep function is implemented in AngelScript, and it is general
enough to allow different kind of sweeping, for example a completely
custom one:

http://arnholm.org/software/as_csg/test_sweep_custom.png

shape@ main_shape()
{
    // specify a custom sweep of a circle profile
    uint   s_nseg = 60;            // sweep #segments
    double s_h    = 100.0;         // sweep height
    double c_rad  = 30;            // circle radius
    shape2d@ xsec = circle(c_rad); // sweep profile

    path_custom path(circle(c_rad),s_h,s_nseg);
    return sweep(path);
}

void main()
{
    shape@ obj = main_shape();
    obj.write_csg(GetOutputFullPath('.csg'));
}


Notice "path_custom" instead of "path_rotate" as in the first example.
The sweep function itself is exactly the same in the 2 cases:

solid@ sweep(path_sweep@ path)
{
     uint nseg = path.nseg(); // # of segments
     double dp = 1.0/nseg;    // delta parameter
     double  p = 0.0;         // start parameter
     solid@ end1 = path.slice(p);
     solid@[] segments;
     for(uint iseg=0; iseg<nseg; iseg++) {
        solid@ end2 = path.slice(p+=dp);
        segments.push_back(hull3d(end1,end2));
        @end1 = @end2;
     }
     return union3d(segments);
}

The point is that the sweep function uses an interface to a path which
can be implemented for various scenarios, of which rotate is only one.

interface path_sweep
{
    uint   nseg();          // number of segments in path
    solid@ slice(double p); // thin slice at parameter p [0,1]
}

In any case, I have put together a Windows installation for anyone who
wants to give it a try. Just download and install. There is no GUI other
than OpenSCAD, "as_csg" is a console program that converts .as files
into OpenSCAD .csg files. A "samples" folder is included, plus a
compiled HTML help file. The samples contain everything to reproduce the
images linked to above.

Here is the download
http://arnholm.org/software/as_csg/AngelScript_CSG_setup_D1.0-00.exe

I guess if you need support, we should not spam this list. Instead you
can send question to me at [hidden email]

Kind regards
Carsten Arnholm

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Generate OpenSCAD models from AngelScript

jpmendes
Hi,
During file download Avast detected a virus in the and blocked the access to the page.

jpmendes
Reply | Threaded
Open this post in threaded view
|

Re: Generate OpenSCAD models from AngelScript

cacb
On 30. des. 2015 23:38, jpmendes wrote:
> Hi,
> During file download Avast detected a virus in the and blocked the access to
> the page.

Hi, check/replace your antivirus. It is a false alarm.

Kind regards
Carsten Arnholm




_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Generate OpenSCAD models from AngelScript

ednisley
On 12/30/2015 05:46 PM, Carsten Arnholm wrote:
> Hi, check/replace your antivirus. It is a false alarm.

Although that's quite likely, you /are/ distributing a closed source
Windows executable that triggers a Virustotal hit for
HEUR/QVM06.1.Malware.Gen:

https://www.virustotal.com/en/file/1ec1b0f19e7789075651d78778dd78b7fdd74bb314afe4e56add98f17bd194f6/analysis/1451519369/

If I were running Windows, I'd treat that file with the same casual
nonchalance as I would any other lump of glowing-hot radioactive metal.

It might be a false alarm or you might be at the leading edge of Yet
Another Windows botnet; there's no way to tell from outside.

--
Ed
softsolder.com

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
 --
Ed
softsolder.com
Reply | Threaded
Open this post in threaded view
|

Re: Generate OpenSCAD models from AngelScript

cacb
On 31. des. 2015 01:02, Ed Nisley wrote:
> If I were running Windows, I'd treat that file with the same casual
> nonchalance as I would any other lump of glowing-hot radioactive metal.

Do as you please. The file is clean.

Now I suggest these reports are sent straight to me with some more
actual facts rather than simple accusations. I have checked and there is
nothing.

Kind regards
Carsten Arnholm




_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Generate OpenSCAD models from AngelScript

Parkinbot
I checked the link to the .exe with virustotal.com. It is clean! The report shows 0/66.
Reply | Threaded
Open this post in threaded view
|

Re: Generate OpenSCAD models from AngelScript

cacb
In reply to this post by ednisley
On 31. des. 2015 01:02, Ed Nisley wrote:
> It might be a false alarm or you might be at the leading edge of Yet
> Another Windows botnet; there's no way to tell from outside.

I can explain why it was a false alarm, I let the setup program
(optionally) update the user PATH so it would be easier to run. I have
removed that feature, so people will have to do it manually. There
really isn't anything nefarious, and there never was.

That's all.

Carsten Arnholm



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Generate OpenSCAD models from AngelScript

jpmendes
This post was updated on .
In reply to this post by cacb
Hi,
I didn't accused you of anything, I simply reported a fact.
After that I navigate your blog just to try to download the file however I couldn't find it.

jpmendes  
Reply | Threaded
Open this post in threaded view
|

Re: Generate OpenSCAD models from AngelScript

cacb
On 31. des. 2015 01:54, jpmendes wrote:
> Hi,
> I didn't accused you of anything, I simply reported a fact.
> After that I navigate your blog just to try to download the file however but
> I couldn't find it.

No problem, see the other comments.

As reported, I cannot access my blog right now, that is why the link
isn't there. The blog will be updated when the access issue is solved.
See the first message for link to Windows executable.

Here is a Linux binary with the exact same features (yes, virus scan ok)
http://arnholm.org/software/as_csg/angelscript_csg_d1.0-11_kubuntu_1510.tar.gz

Built on Linux Kubuntu 15.10 64bit

It loads a shared object so to run you may have to say
LD_LIBRARY_PATH=.


Kind regards
Carsten Arnholm

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Generate OpenSCAD models from AngelScript

cacb
Happy new year to all!

I have been adding features to AngelScript CSG today. As others have
mentioned here, spline curves can be very useful. I have hade the same
idea for some time and have now added 2d and 3d spline curves.

A small example creating an OpenSCAD polygon from a 2d spline curve:
http://arnholm.org/software/as_csg/spline_sample.png

Another example is 3d splines. Below is an example of 3 splines turned
into a lofted surface, turned into an OpenSCAD polyhedron by offsetting
the original surface to create a solid with top an bottom:
http://arnholm.org/software/as_csg/polyhedron_sample.png

You can obviously make it as thick or thing as you like, and you can use
as many/long curves as you want to. They should however not intersect
and should be listed in a logical order.

The complete AngelScript CSG code used for generating the polyhedron:
http://arnholm.org/software/as_csg/polyhedron_sample.as

The result can be displayed in OpenSCAD using this .csg file
http://arnholm.org/software/as_csg/polyhedron_sample.csg

These new features will obviously not run in the version released a few
days ago, as this is brand new.

Have fun.

Carsten Arnholm

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Generate OpenSCAD models from AngelScript

cacb
I have regained access to my blog, and have today added a new post on
generating OpenSCAD models using AngelScript CSG:

http://arnholm.org/angelscript-csg-part-2/

The post explains the updated features as of today. An updated Windows
version can now be downloaded from there. Any feedback welcome.

Have fun.

Carsten Arnholm






_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org