0

Beginners Debug question

How do I get the graphic debug tracing to appear when designing a new shape in the shape generator? I am referring to things like "Debug.line()". I am in the Autodesk Creative Platform Library Editor as the instructions state. I see Debug.log() appearing in the Console ok.

I found your tutorial code in https://api.tinkercad.com/libraries/1vxKXGNaLtr/0/docs/topic/Platonic+Solid+Generator+-+Part+2.html which has debug tracing, but even using it I still cant get it to appear. What am I missing?

Thanks

main.js:-

/ Convenience Declarations For Dependencies.
// 'Core' Is Configured In Libraries Section.
// Some of these may not be used by this example.
var Conversions = Core.Conversions;
var Debug = Core.Debug;
var Path2D = Core.Path2D;
var Point2D = Core.Point2D;
var Point3D = Core.Point3D;
var Matrix2D = Core.Matrix2D;
var Matrix3D = Core.Matrix3D;
var Mesh3D = Core.Mesh3D;
var Plugin = Core.Plugin;
var Tess = Core.Tess;
var Sketch2D = Core.Sketch2D;
var Solid = Core.Solid;
var Vector2D = Core.Vector2D;
var Vector3D = Core.Vector3D;



params = [
  {
    "id": "radius",
    "displayName": "Radius",
    "type": "float",
    "rangeMin": 1,
    "rangeMax": 50,
    "default": 20 }
];



function process(params) {
    var r = params.radius;
    var m = 1 / Math.sqrt(3) * r;
    var phi = (1 + Math.sqrt(5)) / 2;  // The golden ratio, ~1.618

    var r1 = 1 * m;
    var phi1 = phi * m;
    var iphi1 = (1.0 / phi) * m;

    var cubeBot = [];
    cubeBot.push([-r1, -r1, -r1]);
    cubeBot.push([r1, -r1, -r1]);
    cubeBot.push([r1, r1, -r1]);
    cubeBot.push([-r1, r1, -r1]);

    var cubeTop = [];
    cubeTop.push([-r1, -r1, r1]);
    cubeTop.push([r1, -r1, r1]);
    cubeTop.push([r1, r1, r1]);
    cubeTop.push([-r1, r1, r1]);

    var xrect = [];
    xrect.push([0, -iphi1, -phi1]);
    xrect.push([0, -iphi1, phi1]);
    xrect.push([0, iphi1, phi1]);
    xrect.push([0, iphi1, -phi1]);

    var zrect = [];
    zrect.push([-iphi1, -phi1, 0]);
    zrect.push([iphi1, -phi1, 0]);
    zrect.push([iphi1, phi1, 0]);
    zrect.push([-iphi1, phi1, 0]);

    var yrect = [];
    yrect.push([-phi1, 0, -iphi1]);
    yrect.push([phi1, 0, -iphi1]);
    yrect.push([phi1, 0, iphi1]);
    yrect.push([-phi1, 0, iphi1]);

   // if (true) {
        // Draw debug lines to show structures within the dodecahedron:
        // the vertices form a cube and three rectanges on each axis.
        Debug.color(1, 0.65, 0, 1);
        Debug.line(cubeBot[0], cubeBot[1]);
        Debug.line(cubeBot[1], cubeBot[2]);
        Debug.line(cubeBot[2], cubeBot[3]);
        Debug.line(cubeBot[3], cubeBot[0]);

        Debug.line(cubeTop[0], cubeTop[1]);
        Debug.line(cubeTop[1], cubeTop[2]);
        Debug.line(cubeTop[2], cubeTop[3]);
        Debug.line(cubeTop[3], cubeTop[0]);

        Debug.line(cubeBot[0], cubeTop[0]);
        Debug.line(cubeBot[1], cubeTop[1]);
        Debug.line(cubeBot[2], cubeTop[2]);
        Debug.line(cubeBot[3], cubeTop[3]);

        Debug.color(0, 0.8, 0, 1);
        Debug.line(xrect[0], xrect[1]);
        Debug.line(xrect[1], xrect[2]);
        Debug.line(xrect[2], xrect[3]);
        Debug.line(xrect[3], xrect[0]);

        Debug.color(0, 0.1, 1.0, 1);
        Debug.line(zrect[0], zrect[1]);
        Debug.line(zrect[1], zrect[2]);
        Debug.line(zrect[2], zrect[3]);
        Debug.line(zrect[3], zrect[0]);

        Debug.color(1, 0.2, 0.8, 1);
        Debug.line(yrect[0], yrect[1]);
        Debug.line(yrect[1], yrect[2]);
        Debug.line(yrect[2], yrect[3]);
        Debug.line(yrect[3], yrect[0]);
   // }
 
    var mesh = new Mesh3D();

    function penta(a, b, c, d, e) {
        mesh.triangle(a, e, d);
        mesh.triangle(a, d, c);
        mesh.triangle(a, c, b);
    }

    penta(cubeTop[0], xrect[1], cubeTop[1], zrect[1], zrect[0]);
    penta(cubeTop[2], xrect[2], cubeTop[3], zrect[3], zrect[2]);

    penta(cubeBot[1], xrect[0], cubeBot[0], zrect[0], zrect[1]);
    penta(cubeBot[3], xrect[3], cubeBot[2], zrect[2], zrect[3]);

    penta(xrect[0], xrect[3], cubeBot[3], yrect[0], cubeBot[0]);
    penta(xrect[3], xrect[0], cubeBot[1], yrect[1], cubeBot[2]);

    penta(xrect[2], xrect[1], cubeTop[0], yrect[3], cubeTop[3]);
    penta(xrect[1], xrect[2], cubeTop[2], yrect[2], cubeTop[1]);

    penta(cubeTop[2], zrect[2], cubeBot[2], yrect[1], yrect[2]);
    penta(cubeBot[1], zrect[1], cubeTop[1], yrect[2], yrect[1]);

    penta(cubeBot[3], zrect[3], cubeTop[3], yrect[3], yrect[0]);
    penta(cubeTop[0], zrect[0], cubeBot[0], yrect[0], yrect[3]);

    return Solid.make(mesh);
}

1 comment

Please sign in to leave a comment.