[Solved]How to Call Save function on my Script?
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: How to Call Save function on my Script?
Doesn't sound right. However, without context, I cannot help. Can you ZIP / attach your scripts/luSYS?
-
- Full Member
- Posts: 58
- Joined: Wed Mar 16, 2016 5:10 pm
Re: How to Call Save function on my Script?
Here it goes.
Sorry for the trouble, and thank you.
Sorry for the trouble, and thank you.
Last edited by Ghost_of_Magellan on Fri Jun 03, 2016 12:42 pm, edited 1 time in total.
Re: How to Call Save function on my Script?
OK, thanks. I'll have a look when time allows.
-
- Full Member
- Posts: 58
- Joined: Wed Mar 16, 2016 5:10 pm
Re: How to Call Save function on my Script?
Can't ask for anything more.
Thank you.
Thank you.
Re: How to Call Save function on my Script?
Try adding this at the very end of your beginEvent function:
However, it might also create other problems since your FirstWidget object is then immediately destroyed which means all references to this / self will stop working or crash. You can probably work around this by using EAction.getDocumentInterface instead of self.getDocumentInterface.
My recommendation would be:
- FirstWidget.init should create the dock widget (probably hidden by default).
- The class FirstWidget should only show / hide the dock widget in beginEvent.
- Everything else is handled by a separate class which is the actual implementation of your dock widget.
All QCAD dock widgets are built that way (LayerList, BlockList, etc.).
this.terminate();This should fix the termination problem when the widget is shown.
However, it might also create other problems since your FirstWidget object is then immediately destroyed which means all references to this / self will stop working or crash. You can probably work around this by using EAction.getDocumentInterface instead of self.getDocumentInterface.
My recommendation would be:
- FirstWidget.init should create the dock widget (probably hidden by default).
- The class FirstWidget should only show / hide the dock widget in beginEvent.
- Everything else is handled by a separate class which is the actual implementation of your dock widget.
All QCAD dock widgets are built that way (LayerList, BlockList, etc.).
-
- Full Member
- Posts: 58
- Joined: Wed Mar 16, 2016 5:10 pm
Re: How to Call Save function on my Script?
Well, it does work like this:
With this.terminate(); The save function does work, however, when the button is pressed, nothing happens. The save is only concluded and the save window opened when I change windows(alt tab into another program, for example). After that the save window appears immediately. If I don't do this, the window will not appear no matter how much I wait.
Without this.terminate(); The first time I press save I can get the window to appear by right clicking or Esc. This only happens the first time. After that I have to change work windows, as described above.
So the this.terminate(); does not seem to be of great impact, on this matter, at least.
Your suggestion about the widget creation on initialization seems to be the most appropriate, and it is within my plans to follow it through when I have the time, though for now I'm somewhat eager just to have a decently functioning app. And though the app is, technically working, lets be frank, this error is stupid.
An off topic question, if I may.
Imagine that I have two entities on top of one another. I can change the colour of one of them to highlight it on the drawing board, but if it's UNDER the other entity, it will still be hard to see it. What command/function can I use to push to the entity back or to the front in relation to the other?
Thank you.
docInterface = EAction.getDocumentInterface(); widgets["cmd_Save"].clicked.connect(function () { if(nr_linhas > 0 && entityIds.length>0){ if (vl_nr_selected > 0){ entityIds = WipeLastCircle(doc, docInterface, entityIds); SetLastColors(doc, docInterface, entityIds, last_id, last_color); } nr_linhas = DoRefresh(doc, docInterface, widgets, entityIds, nr_linhas); var vl_save = new Save(); docInterface.queueAction(vl_save); } }); this.terminate();I have tried this with and without the this.terminate(); option. These are my observations:
With this.terminate(); The save function does work, however, when the button is pressed, nothing happens. The save is only concluded and the save window opened when I change windows(alt tab into another program, for example). After that the save window appears immediately. If I don't do this, the window will not appear no matter how much I wait.
Without this.terminate(); The first time I press save I can get the window to appear by right clicking or Esc. This only happens the first time. After that I have to change work windows, as described above.
So the this.terminate(); does not seem to be of great impact, on this matter, at least.
Your suggestion about the widget creation on initialization seems to be the most appropriate, and it is within my plans to follow it through when I have the time, though for now I'm somewhat eager just to have a decently functioning app. And though the app is, technically working, lets be frank, this error is stupid.
An off topic question, if I may.
Imagine that I have two entities on top of one another. I can change the colour of one of them to highlight it on the drawing board, but if it's UNDER the other entity, it will still be hard to see it. What command/function can I use to push to the entity back or to the front in relation to the other?
Thank you.
Re: How to Call Save function on my Script?
Try this to trigger Save / SaveAs:
var a = RGuiAction.getByScriptFile("scripts/File/Save/Save.js"); docInterface.setCurrentAction(new Save(a));The problem is that those inline functions are running in whatever script context that is active when the user presses the button.
That would be the "Draw Order" property.Ghost_of_Magellan wrote:Imagine that I have two entities on top of one another. I can change the colour of one of them to highlight it on the drawing board, but if it's UNDER the other entity, it will still be hard to see it. What command/function can I use to push to the entity back or to the front in relation to the other?
-
- Full Member
- Posts: 58
- Joined: Wed Mar 16, 2016 5:10 pm
Re: How to Call Save function on my Script?
Works perfectly!!
Thank you, andrew.
Thank you, andrew.