QCAD Project
Moderators: andrew, Husky, J-J
QCAD Project
Hi!
I recently posted an outline of my intentions in the new user area.
http://www.qcad.org/rsforum/viewtopic.php?f=55&t=4325
I have a question on receiving events from a UI created in Qt Designer.
I would like to use the search button to modify a listView's query as seen in this image.
Currently I have this dialog box pop up when I run a script from a menu item.
How can I read the text in the search box when a user presses the Search button?
Thanks for any help.
Connor
I recently posted an outline of my intentions in the new user area.
http://www.qcad.org/rsforum/viewtopic.php?f=55&t=4325
I have a question on receiving events from a UI created in Qt Designer.
I would like to use the search button to modify a listView's query as seen in this image.
Currently I have this dialog box pop up when I run a script from a menu item.
How can I read the text in the search box when a user presses the Search button?
Thanks for any help.
Connor
Re: QCAD Project
I've been reading about signals/slots in Qt.
To handle the "Search" button on-click event, you must connect the signal to a slot.
In this case, I connect an in-line function to the on-click signal.
The following code can be used:
To handle the "Search" button on-click event, you must connect the signal to a slot.
In this case, I connect an in-line function to the on-click signal.
The following code can be used:
var button = dialog.findChild("pushButton"); button.clicked.connect( function() { appWin.handleUserMessage("button pressed"); });When the user clicks the search button, "button pressed" is printed in the command history in QCAD.
Last edited by cjh on Mon Jul 25, 2016 8:12 pm, edited 1 time in total.
Re: QCAD Project
I'm trying to set up a filter on my tableView shown above.
It looks like I should be using QSortFilterSqlQueryModel() to connect my text box's textChanged signal to the filter function available in QSortFilterSqlQueryModel.
When I try this:
there is an error "can't find variable" when I try to run the script.
QSortFilterSqlQueryModel is included in QtCore, but it doesn't seem to have made it to QCAD.
How can I include the QSortFilterSqlQueryModel.h that exists in a full installation of Qt?
Please let me know if I'm looking at this incorrectly.
****EDIT****
I'm using a QSqlTableModel as a workaround to a QSortFilterSqlQueryModel.
As a side note, is there a way to call the Synchronize Attributes command from a script?
This will make my Title Block update much cleaner.
I believe it's hidden in qcadproscripts.dll and I can't figure out how to call it.
Connor
It looks like I should be using QSortFilterSqlQueryModel() to connect my text box's textChanged signal to the filter function available in QSortFilterSqlQueryModel.
When I try this:
Code: Select all
var partsProxy = new QSortFilterSqlQueryModel();
QSortFilterSqlQueryModel is included in QtCore, but it doesn't seem to have made it to QCAD.
How can I include the QSortFilterSqlQueryModel.h that exists in a full installation of Qt?
Please let me know if I'm looking at this incorrectly.
****EDIT****
I'm using a QSqlTableModel as a workaround to a QSortFilterSqlQueryModel.
As a side note, is there a way to call the Synchronize Attributes command from a script?
This will make my Title Block update much cleaner.
I believe it's hidden in qcadproscripts.dll and I can't figure out how to call it.
Connor
Re: QCAD Project
You should be able to trigger the tool using:cjh wrote:As a side note, is there a way to call the Synchronize Attributes command from a script?
var guiAction = RGuiAction.getByScriptFile("scripts/Pro/Block/Attribute/AttributeSynchronization/AttributeSynchronization.js"); if (!isNull(guiAction)) { guiAction.slotTrigger(); }Note that the file "scripts/Pro/Block/Attribute/AttributeSynchronization/AttributeSynchronization.js" is embedded as resource in the QCAD Professional plugin (qcadproscripts.dll).
Re: QCAD Project
Thanks andrew.
Is it possible to see a list of the available functions provided by qcadproscripts.dll?
I'm writing a script to handle batch operations on all drawings in a folder.
I want to use it to change an attribute (Total Number of Pages) in a title block.
Is there a change attribute operation?
I'll keep digging!
Connor
Is it possible to see a list of the available functions provided by qcadproscripts.dll?
I'm writing a script to handle batch operations on all drawings in a folder.
I want to use it to change an attribute (Total Number of Pages) in a title block.
Is there a change attribute operation?
I'll keep digging!
Connor
Re: QCAD Project
The QCAD Pro tools should not be considered part of the API (even tough you can trigger individual tools as described above).cjh wrote:Is it possible to see a list of the available functions provided by qcadproscripts.dll?
You can get a list of all tools, including QCAD Pro tools under Help > About.. > Scripts
You'd typically proceed like this:cjh wrote:Is there a change attribute operation?
- query the block reference entity (RDocument::getBlockId(), RDocument::queryBlockReferences())
- query the child entities (=block attributes) of the block reference (RDocument::queryChildEntities)
- the child entities are of type RAttributeEntity, so you can find the desired attributes based on its tag
- change attribute as desired, as usual in an operation:
var op = new RAddObjectOperation(attribute); di.applyOperation(op);
Re: QCAD Project
Right. I go through the first three steps as outlined.
BlockListAttributes.js was particularly helpful here.
When I run the following, attribute value changes do not show up until I select the edited block.
These changes are not undoable.
Should I be using a Modify Operation on the attributes that already exist in the block?
BlockListAttributes.js was particularly helpful here.
When I run the following, attribute value changes do not show up until I select the edited block.
These changes are not undoable.
Should I be using a Modify Operation on the attributes that already exist in the block?
var attVal; // attribute value from attMap var attributeIds = doc.queryChildEntities(bRefID, RS.EntityAttribute); var op = new RAddObjectsOperation(); for (var i=0; i<attributeIds.length; i++) { var attributeId = attributeIds; var attribute = doc.queryEntityDirect(attributeId); if (attribute.isNull()) { continue; } attVal = att_val_Map.get(attribute.getTag(), null); if (isNull(attVal)) { //skip attributes wihtout values defined in the map continue; } // have valid attribute + value pair attribute.setText(attVal); op.addObject(attribute); } di.applyOperation(op);
Re: QCAD Project
queryEntityDirect should only be used to speed up performance when using an entity to retrieve data (read-only).
Entities that are modified and added to operations should be queried using queryEntity instead. This ensures that the modifications are then made on a clone of the entity and when the operation is applied, the difference can be recorded for undo / redo.
Entities that are modified and added to operations should be queried using queryEntity instead. This ensures that the modifications are then made on a clone of the entity and when the operation is applied, the difference can be recorded for undo / redo.
Re: QCAD Project
AWESOME!
Thanks for the quick reply - that was it!
The whole operation process makes a lot more sense now.
Once I clean up the code for this I'll post it for others.
Next order of business will be producing a Bill of Materials from the blocks in a drawing.
Does anyone have any suggestions on how to store the part information for the drawing?
I will be pulling it from a database and formatting it within the drawing.
I will probably make a new drawing tool "Table" that draws a table of the items.
Connor
Thanks for the quick reply - that was it!
The whole operation process makes a lot more sense now.
Once I clean up the code for this I'll post it for others.
Next order of business will be producing a Bill of Materials from the blocks in a drawing.
Does anyone have any suggestions on how to store the part information for the drawing?
I will be pulling it from a database and formatting it within the drawing.
I will probably make a new drawing tool "Table" that draws a table of the items.
Connor
Re: QCAD Project
Custom properties might come in handy to attach custom information to objects (i.e. entities, layers, blocks).cjh wrote:Does anyone have any suggestions on how to store the part information for the drawing?
An example for adding a custom property to a layer can be found at:
https://github.com/qcad/qcad/tree/maste ... omProperty
Functions related to custom properties are part of the RObject class.
Re: QCAD Project
Connor: I've split your new question into a new topic at:
http://www.qcad.org/rsforum/viewtopic.php?f=33&t=4340
http://www.qcad.org/rsforum/viewtopic.php?f=33&t=4340