Hi Andrew,
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.
Thanks,
Andrew.
[SOLVED] Snapping restrictions
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.
[SOLVED] Snapping restrictions
Last edited by Taygete on Tue Mar 24, 2015 9:14 am, edited 1 time in total.
Re: Snapping restrictions
You can use setSnapRestriction through the document interface:
di.setSnapRestriction(new RRestrictAngleLength(di));
Re: Snapping restrictions
Hi Andrew,
Thanks for the guidance.
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?
Thanks,
Andrew.
Thanks for the guidance.
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?
Thanks,
Andrew.
Re: Snapping restrictions
No. This sets the restriction mode for the document. UI components are handled on a different level entirely.Taygete wrote:it still doesn't 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):I was hoping I could add the "Restrict Angle or Length" ui components to my tools optionsbar
var guiAction = RGuiAction.getByScriptFile("scripts/Snap/RestrictAngleLength/RestrictAngleLength.js"); guiAction.trigger();
Re: Snapping restrictions
Hi Andrew,
Thanks for the information.
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.
Thanks,
Andrew.
Thanks for the information.
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.
Thanks,
Andrew.
Re: Snapping restrictions
I see. Don't remember from the top of my head how that is implemented. Can you try:
di.setSnapRestriction(new RRestrictAngleLengthExtension(di));
Re: Snapping restrictions
Hi Andrew,
Thanks for the info.
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
otherwise RRestrictAngleLengthExtension is unrecognised.
Thanks,
Andrew.
Thanks for the info.
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
Code: Select all
include("scripts/Snap/RestrictAngleLength/RestrictAngleLength.js");
Thanks,
Andrew.