I was wondering if there is a way to switch on snapping restrictions from within a script without the user having to select the restriction from the snap tools palette?
I can see you allow a user to enable the restrict angle length in the Line2P.js script but this is enabled via a button on the toolbar, I would like to enable this so it is always on in my script without the need for the user to enable it.
I had tried this previously but without success, so I tried again but it still doesn’t add the “Restrict Angle or Length” ui components to my tools optionsbar. The only way I can get it too work is if I physically click the option from the CAD Tools bar.
I was hoping I could add the “Restrict Angle or Length” ui components to my tools optionsbar in code so the user doesn’t need to click the restriction in the CAD Tool bar, should I be doing something else as well?
No. This sets the restriction mode for the document. UI components are handled on a different level entirely.
I was hoping I could add the “Restrict Angle or Length” ui components to my tools optionsbar
You could trigger the restriction tool programmatically (this is user interface level stuff):
var guiAction = RGuiAction.getByScriptFile(“scripts/Snap/RestrictAngleLength/RestrictAngleLength.js”);
guiAction.trigger();
That got me a bit closer, the “Restrict Angle or Length” button in the CADTools is highlighted however I still don’t get the “Restrict Angle or Length” ui components added to my tools optionsbar until I click the “Restrict Angle or Length” button on the CADTools.
I guess I must be doing something wrong but can’t see what at the moment.
It worked okay this time, I had tried calling setSnapRestriction previously on an earlier build of QCAD (version 3.6.1 I think) and couldn’t get it to work however it works fine on 3.9.1.
I also needed to include the RestrictAngleLength.js script