Can I have some code for spline please?
Where do I find the list of commands that can be used in the script file.
I am a beginner and am using qcad 3.0
Thanks
script for spline
Moderator: andrew
Forum rules
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
Re: script for spline
You can actually find code for pretty much anything that is possible in the scripts that come with QCAD 3 in the scripts directory.
For example search all .js files for RSpline, RSplineEntity, RSplineData.
The complete API is documented at:
http://www.qcad.org/doc/qcad/latest/developer/
Spline entity class:
http://www.qcad.org/doc/qcad/latest/dev ... ntity.html
For example search all .js files for RSpline, RSplineEntity, RSplineData.
The complete API is documented at:
http://www.qcad.org/doc/qcad/latest/developer/
Spline entity class:
http://www.qcad.org/doc/qcad/latest/dev ... ntity.html
-
- Junior Member
- Posts: 16
- Joined: Mon Jan 07, 2013 9:43 am
Re: script for spline
Thanks!
It more or less set me on my way.
It more or less set me on my way.
-
- Junior Member
- Posts: 16
- Joined: Mon Jan 07, 2013 9:43 am
Re: script for spline
One more question though.
How can the values be accepted from command line?
I want to prompt the user for input which could be strings, numbers and based on the values determine the action in a program
How can the values be accepted from command line?
I want to prompt the user for input which could be strings, numbers and based on the values determine the action in a program
Re: script for spline
If the user enters a coordinate in the command line, your class triggers 'pickCoordinate(event, preview)'.
Where 'event.getModelPosition()' is an RVector with the coordinate entered and 'preview' is 'true' if the user is still busy entering the coordinate and 'false' if the user has pressed enter to confirm the input.
'pickCoordinate' is also called when the user clicks a coordinate with the mouse, so you might already have that implemented anyway.
If the user enters anything that is not a coordinate (i.e. a double value or simply text), 'applyCommand(event, preview)' is called. 'event.getCommand()' holds the exact string that was entered by the user. You can separate between values and commands by trying to interpret the input:
For a complete and simple example, have a look at the script 'scripts/Draw/Circle/CircleCR/CircleCR.js' which allows the user to enter the circle radius in the command line, followed by the circle center coordinate.
Where 'event.getModelPosition()' is an RVector with the coordinate entered and 'preview' is 'true' if the user is still busy entering the coordinate and 'false' if the user has pressed enter to confirm the input.
'pickCoordinate' is also called when the user clicks a coordinate with the mouse, so you might already have that implemented anyway.
If the user enters anything that is not a coordinate (i.e. a double value or simply text), 'applyCommand(event, preview)' is called. 'event.getCommand()' holds the exact string that was entered by the user. You can separate between values and commands by trying to interpret the input:
Code: Select all
var value = RMath.eval(event.getCommand());
if (isNaN(value)) {
qDebug("Entered command is: ", event.getCommand());
}
else {
qDebug("Entered value is: ", value);
}
Re: script for spline
I've split the next post to a new topic:
viewtopic.php?f=30&t=2298
viewtopic.php?f=30&t=2298