Page 1 of 1
Sript & blocks
Posted: Wed Nov 30, 2011 1:24 pm
by patsol
Bonjour,
Je ne trouve pas comment manipuler des blocks (afficher, masquer, insérer, ajouter...) à partir d'un script.
Est-ce possible?
Merci,
Posted: Wed Nov 30, 2011 2:50 pm
by andrew
I'm assuming you are asking about QCAD 3.
Je suppose que vous parlez QCAD 3.
Code: Select all
var document = this.getDocument();
var di = this.getDocumentInterface();
// create new block definition:
var block = new RBlock(document, "MyBlock", new RVector(0,0));
var operation = new RAddObjectOperation(block);
di.applyOperation(operation);
// make new block the current block:
di.setCurrentBlock("MyBlock");
// add a line and an arc to the block definition:
var p1 = new RVector(0,0);
var p2 = new RVector(50,0);
var line = new RLineEntity(document, new RLineData(p1, p2));
var center = new RVector(25,0);
var radius = 25;
var arc = new RArcEntity(document, new RArcData(center, radius, 0.0, Math.PI, false));
operation = new RAddObjectsOperation();
operation.addObject(line);
operation.addObject(arc);
di.applyOperation(operation);
// switch back to main drawing (block "*Model_Space"):
di.setCurrentBlock("*Model_Space");
// create block reference in main drawing at 10/20, scale 1, angle 30:
var position = new RVector(10,20);
var scale = new RVector(1,1);
var angle = RMath.deg2rad(30);
var blockId = document.getBlockId("MyBlock");
var blockRef = new RBlockReferenceEntity(document, new RBlockReferenceData(blockId, position, scale, angle));
operation = new RAddObjectOperation(blockRef);
di.applyOperation(operation);
Posted: Wed Nov 30, 2011 5:12 pm
by patsol
Thank you, Andrew, for your answer.
No i am asking about QCAD2.
your code is not running with this.
Another solution
Posted: Wed Nov 30, 2011 6:54 pm
by andrew
patsol wrote:Another solution
No, QCAD 2 scripting is limited to creating some common, simple entities. You might want to consider an update to QCAD 3 for serious script development. QCAD 3 offers a very complete scripting API.
Non, QCAD 2 scripts sont limités à la création des entités simples. Vous pourriez envisager une mise à jour QCAD 3 pour l'élaboration du scénario avancé. QCAD 3 offre une API de scripts très complète.
Posted: Fri Dec 02, 2011 8:09 am
by patsol
Posted: Fri Dec 02, 2011 2:46 pm
by patsol
Il n'y a plus d' IDE?
Posted: Fri Dec 02, 2011 10:57 pm
by andrew
No, QCAD 3 has no scripting IDE.
The reason is that the Qt framework on which QCAD is based on offers no longer a script IDE for the new Qt (ECMAScript) scripting.
However, QCAD 3 does have a script debugger that pops up on exceptions (or when finding a debugger; statement).
Non, QCAD 3 n'a pas de script IDE.
La raison est que le framework Qt sur lequel QCAD est basé n'offre plus un IDE script pour le nouveau Qt (ECMAScript) scripting.
Toutefois, QCAD 3 a un débogueur de script qui apparaît sur les exceptions (ou lorsque la recherche d'un debugger; déclaration).
Posted: Sat Dec 03, 2011 8:31 am
by patsol
QCAD 3 a un débogueur de script qui apparaît sur les exceptions (ou lorsque la recherche d'un debugger; déclaration).
Malheureusement, je m'en suis apperçu très vite!