I have many drawings that will be based on a predetermined set of data in key-value pairs. I think that an XML document file would be ideal for this purpose. My question is - If I create a QT form asking for the values on a list of keys, can I save this within the QCAD file structure to be chosen at any time in the future as a basis for a new drawing?
I need the data to be persistent, because re-entering it constantly would become tiresome. This is preliminary, but I think I'll create items as dynamic parts to put in the library with all the scripts necessary to make a drawing. Those scripts will need the key-value data to draw the part with the appropriate dimensions.
I was unable to locate anything in the ECMA Script language specification in regard to writing or reading an XML document. There is a lot of information available for doing this in a browser DOM (for example: http://www.w3schools.com/dom/dom_nodes_access.asp), but I don't think that is going to help.
Worst case scenario, I can create an XML template file that would require the user to fill in the values and save it. But I still need to be able to read it with QCAD.
Has anyone done this or have any suggestions?
Save Persistent Data within QCAD App
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.
-
- Full Member
- Posts: 84
- Joined: Sat Nov 03, 2012 2:00 am
Re: Save Persistent Data within QCAD App
Qt comes with classes for XML reading (QXmlSimpleReader, QXmlInputSource, QXmlDefaultHandler) and writing (QXmlStreamWriter).
I've added two brief examples that demonstrate reading and writing of XML data.
XML Import:
Save these two files into scripts/Misc/Examples/IOExamples/ExXmlImport of your QCAD installations (create missing folders if necessary):
https://raw.githubusercontent.com/qcad/ ... lImport.js
https://raw.githubusercontent.com/qcad/ ... ortInit.js
XML Export:
Save these two files into scripts/Misc/Examples/IOExamples/ExXmlExport of your QCAD installations (create missing folders if necessary):
https://raw.githubusercontent.com/qcad/ ... lExport.js
https://raw.githubusercontent.com/qcad/ ... ortInit.js
I've added two brief examples that demonstrate reading and writing of XML data.
XML Import:
Save these two files into scripts/Misc/Examples/IOExamples/ExXmlImport of your QCAD installations (create missing folders if necessary):
https://raw.githubusercontent.com/qcad/ ... lImport.js
https://raw.githubusercontent.com/qcad/ ... ortInit.js
XML Export:
Save these two files into scripts/Misc/Examples/IOExamples/ExXmlExport of your QCAD installations (create missing folders if necessary):
https://raw.githubusercontent.com/qcad/ ... lExport.js
https://raw.githubusercontent.com/qcad/ ... ortInit.js
-
- Full Member
- Posts: 84
- Joined: Sat Nov 03, 2012 2:00 am
Re: Save Persistent Data within QCAD App
I never even looked at QT. I have never used QT before and was hoping that I could squeak by learning just forms/dialogs. It looks like I need to learn more than that to do what I want to do.
Thank you for providing these scripts. This is exactly what I was looking for.
Lori
Thank you for providing these scripts. This is exactly what I was looking for.
Lori
Re: Save Persistent Data within QCAD App
You probably can do that for most things. You might even find JavaScript resources out there to do what you want. The posted code is just what I would use if I had to deal with XML files.wildspidee wrote:I never even looked at QT. I have never used QT before and was hoping that I could squeak by learning just forms/dialogs.
Having said that, Qt is a very complete tool kit which covers everything from GUI, graphics and printing to network, multimedia and database interaction. It's very well organised and likely worth your effort.
-
- Full Member
- Posts: 84
- Joined: Sat Nov 03, 2012 2:00 am
Re: Save Persistent Data within QCAD App
Andrew,
I would rather do this right than do it quickly. Whatever you would use, is what I want to do. I have wanted to do this QCAD add-on for over two years, but every time I started I became intimidated because I know very little Javascript, no QT and zero C++. I'm self taught, usually using just documentation and manuals when I can find them. Your documentation is superior, so I'm sure everything I need is in there. I need to become familiar with the terminology and syntax.
I just need to make the investment in time and get this going, whatever it takes. I have a lot of people interested in QCAD and if I can automate these processes, there will be many, many more. I had a person post to my blog who says he's working with Dreamworks and he was asking for help in pattern drafting. I don't know if he's for real, but that gives you some idea of the scope of this project.
Thanks again,
Lori
I would rather do this right than do it quickly. Whatever you would use, is what I want to do. I have wanted to do this QCAD add-on for over two years, but every time I started I became intimidated because I know very little Javascript, no QT and zero C++. I'm self taught, usually using just documentation and manuals when I can find them. Your documentation is superior, so I'm sure everything I need is in there. I need to become familiar with the terminology and syntax.
I just need to make the investment in time and get this going, whatever it takes. I have a lot of people interested in QCAD and if I can automate these processes, there will be many, many more. I had a person post to my blog who says he's working with Dreamworks and he was asking for help in pattern drafting. I don't know if he's for real, but that gives you some idea of the scope of this project.
Thanks again,
Lori