3DCoatScripting  4.8.31ฮฒ
You can manage 3Dะกoat features with help of scripting
๐ŸŒ€ Script debugging

Scripts in 3DCoat could be very complex, as they are written with AngelScript, which is used in many big successful projects

That's why while writing your own script you'll might need to know the values of some variables And you can.

Insert this code in the beginning of your scripts, and you'll be able to:

  • print to a log-file (log)
  • draw in scene (drw)
// access to debugging
Debug dbg;
void main() {
// text log
// open from "Script / Show Execution Log"
DebugLog log = dbg.log();
// prepare text log
log.clear();
// viewport
// see graphics immediately
DebugDraw drw = dbg.draw();
// prepare the viewport
// 1) clear
// 2) choose default brush color
drw.clear().color( 0xFFFFEE00 );
// write here what would you like to show / display
// ...
}

What can we print to a log-file?

// values of certain variables
float delta = 1.2345;
log += delta;
// results of math operations
log += pow( a, 3 ) * sqrt( 2 ) / 12;
// text / notes
log +=
"This is a debug-note."
" We do treat variables provisionally as constants.";
// all declared local variables
log += dbg.vars();
// or ("or" will be skipped later on when several options listed)
log += dbg.variables();
// all declared global variables
log += dbg.gvars();
log += dbg.globalVariables();
// current call stack
log += dbg.callstack();
// mesh
// mesh structure will appear on text form
Builder builder;
const Mesh a = builder.cylinder()
.positionTop( Vec3( 0, 120, 0 ) )
.positionBottom( Vec3( 0, 0, 0 ) )
.radiusTop( 50 )
.radiusBottom( 50 )
.details( 0.1 )
();
log += a;

What can be displayed in the viewport?

// point
// point( position, color )
drw.point( Vec3( 50, 0, 0 ) );
drw.point( Vec3( 50, 60, 0 ), Color( 0xFFAAFF33 ) );
// line
// line( startPosition, endPosition, startColor, endColor )
drw.line( Vec3( 0, 0, 0 ), Vec3( 100, 50, 25 ) );
drw.line( Vec3( 0, 50, 0 ), Vec3( 0, 200, 25 ),
Color( 0xFF33FF33 ) );
drw.line( Vec3( 100, 120, 0 ), Vec3( 100, 250, 25 ),
Color( 0xFFAA0000 ), Color( 0xFF0000AA ) );
// circle
// circle( position, normal, radius, color )
drw.circle( Vec3( 0, 0, 0 ), Vec3( 100, 50, 25 ), 20 );
drw.circle( Vec3( 0, 50, 0 ), Vec3( 0, 200, 25 ), 50,
Color( 0xFF55FFAA ) );
// sphere
// sphere( position, radius, color )
drw.sphere( Vec3( 0, 0, 0 ), 15 );
drw.sphere( Vec3( 0, 50, 0 ), 45,
Color( 0x9955FFAA ) );
// triangle
// triangle( A, B, C, colorA, colorB, colorC )
const Vec3 a( 0, 0, 0 );
const Vec3 b( 80, 30, 70 );
const Vec3 c( 10, 25, 100 ) );
drw.triangle( a, b, c );
drw.triangle( a, b, c,
Color( 0x77AA0000 ) );
drw.triangle( a, b, c,
Color( 0xFFAA0000 ), Color( 0xFF00AA00 ), Color( 0xFF0000AA ) );
// note, number
// note( position, text )
drw.note( Vec3( 0, 0, 0 ), "Note A" );
drw.note( Vec3( 0, 30, 0 ), "Note B",
Color( 0xFF33FF33 ) );
drw.note( Vec3( 0, 0, 20 ), 111 );
drw.note( Vec3( 0, 30, 20 ), 222.51,
Color( 0xFF33FF33 ) );

Vectors, Matrix, boxes and so on: apparently, that they are printed / visualized simply:

log += MyObjectThatIWantToPrint;
drw += MyObjectThatIWantToDraw;

More complex visualization can be split into layers in order to show/hide them separately:

drw += "First";
// or `drw.layer( "First" );`
// now all is drawn on layer `First`
// ...
drw += "Second";
// now - in layer `Second`
// ...
See Also
๐ŸŒ€ How to make a script
DebugDraw
DebugLog