Sript & blocks

Veuillez poser ici vos questions, vos commentaires, concernant l'utilisation ou les problèmes rencontrés avec QCAD professionnel

Moderators: andrew, J-J

Sript & blocks

Postby patsol » Wed Nov 30, 2011 1:24 pm

Bonjour,

Je ne trouve pas comment manipuler des blocks (afficher, masquer, insérer, ajouter...) à partir d'un script.

Est-ce possible?

Merci,
patsol
Junior Member
 
Posts: 15
Joined: Wed Nov 30, 2011 1:15 pm

Postby andrew » Wed Nov 30, 2011 2:50 pm

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);
User avatar
andrew
Site Admin
 
Posts: 2602
Joined: Fri Mar 30, 2007 6:07 am

Postby patsol » Wed Nov 30, 2011 5:12 pm

Thank you, Andrew, for your answer.

No i am asking about QCAD2.
your code is not running with this.

Another solution :?:
patsol
Junior Member
 
Posts: 15
Joined: Wed Nov 30, 2011 1:15 pm

Postby andrew » Wed Nov 30, 2011 6:54 pm

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.
User avatar
andrew
Site Admin
 
Posts: 2602
Joined: Fri Mar 30, 2007 6:07 am

Postby patsol » Fri Dec 02, 2011 8:09 am

:shock:
patsol
Junior Member
 
Posts: 15
Joined: Wed Nov 30, 2011 1:15 pm

Postby patsol » Fri Dec 02, 2011 2:46 pm

Il n'y a plus d' IDE?
patsol
Junior Member
 
Posts: 15
Joined: Wed Nov 30, 2011 1:15 pm

Postby andrew » Fri Dec 02, 2011 10:57 pm

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).
User avatar
andrew
Site Admin
 
Posts: 2602
Joined: Fri Mar 30, 2007 6:07 am

Postby patsol » Sat Dec 03, 2011 8:31 am

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! :D
patsol
Junior Member
 
Posts: 15
Joined: Wed Nov 30, 2011 1:15 pm


Return to QCAD Professional

Who is online

Users browsing this forum: No registered users and 2 guests