Je voudrais pouvoir passer un argument à un script que je lance en console
Code: Select all
qcad -autostart MonScript
Quelqu'un peut m'aider?
Code: Select all
qcad -autostart MonScript
Code: Select all
var args = QCoreApplication.arguments();
for (var i=0; i<args.length; i++) {
print("Argument number " + i + ": " + args[i]);
}
Code: Select all
./qcad -autostart myscript.js somefile.txt -x 400
Code: Select all
Argument number 0: qcad
Argument number 1: -autostart
Argument number 2: myscript.js
Argument number 3: somefile.txt
Argument number 4: -x
Argument number 5: 400
QDir.entryList(...) (returns file names) or QDir.entryInfoList(...) (returns array of QFileInfo objects):patsol wrote:Si j'osais, je demanderais encore comment traiter tous les fichiers d'un répertoire.
Code: Select all
// create QDir object that represents a directory:
var dir = new QDir("/Users/andrew");
// get directory listing:
var fileInfos = dir.entryInfoList(
// name filter(s):
["*"],
// we don't want to get information about '.' or '..', we want all directories and all files:
new QDir.Filters(QDir.NoDotAndDotDot, QDir.Dirs, QDir.Files),
// sort by name:
QDir.Name
);
// print some of the available information:
for (var i=0; i<fileInfos.length; i++) {
print(fileInfos[i].fileName(), fileInfos[i].isDir() ? "Directory" : "File", fileInfos[i].size());
}
Code: Select all
Desktop Directory 612
Documents Directory 238
Downloads Directory 442
mydrawing.dxf File 182074
...
Please report to our bug tracker if possible (French is fine, we will translate):patsol wrote:Sous Windows, j'ai quelques bugs que je vais essayer de décrire correctement.
Code: Select all
...
// creating a text entity:
var text = new RTextEntity(document,
new RTextData(
new RVector(10,10), // position
new RVector(10,10), // alignment point
10.0, // height
10.0, // text width (ignored for now)
RS.VAlignTop, // alignments
RS.HAlignCenter,
RS.LeftToRight,
RS.Exact,
1.0, // line spacing factor
"Text string\\PSecond line", // the text
"Arial", // font
false, // bold
false, // italic
0.0, // angle
false // simple text without formatting
)
);
...
Code: Select all
<native>(RVector(10, 10, 0) , RVector(10, 10, 0) , 10, 10, 0, 1, 0, 1, 1, 'Text stringPSecond line', 'Arial', false, false, 0, false) at -1
<anonymous>() at scripts/Examples/MathExamples/UcsImport.js:-1
<global>() at -1
113 false // simple text without formatting
Code: Select all
Uncaught exception at scripts/Examples/MathExamples/UcsImport/UcsImport.js:113: Error: :-1:-1: RTextData(): no matching constructor found.
<native>(RVector(10, 10, 0) , RVector(10, 10, 0) , 10, 10, 0, 1, 0, 1, 1, 'Text stringPSecond line', 'Arial', false, false, 0, false) at -1
<anonymous>() at scripts/Examples/MathExamples/UcsImport/UcsImport.js:-1
<global>() at -1
113 false // simple text without formatting
Code: Select all
// creating a text entity:
var text = new RTextEntity(document,
new RTextData(
new RVector(10,10), // position
new RVector(10,10), // alignment point
10.0, // height
10.0, // text width (ignored for now)
RS.VAlignTop, // alignments
RS.HAlignCenter,
RS.LeftToRight,
RS.Exact,
1.0, // line spacing factor
"Text string\\PSecond line", // the text
"Arial", // font
false, // bold
false, // italic
0.0, // angle
false // simple text without formatting
)
);
Code: Select all
var td = new RTextData();
td.setText("My Text");
td.setTextHeight(10.0);
td.setPosition(new RVector(10.0,10.0));
td.setAlignmentPoint(new RVector(10.0,10.0));
// set more attributes...
var text = new RTextEntity(document, td);