Graeme Posted December 22, 2009 Report Share Posted December 22, 2009 Hello, I'm trying to build a project programmatically. The "Add Files to Project" example VI is a really good start but I'm trying to take it further. However, I'm struggling! I'd like to add a build specification under "Build Specifications", akin to right-clicking on "Build Specifications" and selecting "New">"Application (EXE)", and configuring it appropriately. The "ProjectItem:AddItem" method seems the way forward, with perhaps "Application (EXE)" (guessing) as the "Type" input, but "Name" and "Path" inputs baffle me somewhat. Has anyone any pointers for me? All I want to do is copy the build spec. from one project to another. Searches have revealed little. Regards, GGT. Quote Link to comment
Mark Smith Posted December 22, 2009 Report Share Posted December 22, 2009 You can learn most of what you need to know by decomposing an existing project. Use a property node with the VI Server - Application class and then the Projects.Projects[] property to get a list of all the projects open - iterate thru the projects and get the Name property of the project and see if that's the one you want - if there's only one project open, then it will be easy. Then, from the MyComputer property of the Project, use a property node (it will become a TargetItem property node when wired to the MyComputer ref), you can get a BuildSpecs property and then the children of that ref are the actual build specifications (source dist, exe, installer, etc). Once you get a ref to the right kind of build spec (sounds like an EXE in your case) you can see all the properties for that type of object and the methods you can invoke by wiring property and invoke nodes. Then, it should start to become sort of clear what you need to write to your project file to create a new build spec. This is all clear as mud, but that's the only way I ever figured out how to programmatically change a project. I've never created a new build spec programmatically, but I do have code that modifies build specs and saves them back to the project. It might be easier to create a "template" build spec in your project and then modify that rather than have to create one from scratch. Mark Quote Link to comment
Ryan Podsim Posted December 23, 2009 Report Share Posted December 23, 2009 (edited) I was playing around with this idea, (since I've been thinking of trying the same thing) and came up with the following project. If you open the project the only VI scans the first open project(to work this needs to be the only open project) and shows all build specs and creates a build spec. It doesn't modify any of the settings but that should be easy once the spec is created. Sandbox Project.zip Edited December 23, 2009 by RyanPodsim Quote Link to comment
jgcode Posted December 23, 2009 Report Share Posted December 23, 2009 Hello, I'm trying to build a project programmatically. The "Add Files to Project" example VI is a really good start but I'm trying to take it further. However, I'm struggling! I'd like to add a build specification under "Build Specifications", akin to right-clicking on "Build Specifications" and selecting "New">"Application (EXE)", and configuring it appropriately. The "ProjectItem:AddItem" method seems the way forward, with perhaps "Application (EXE)" (guessing) as the "Type" input, but "Name" and "Path" inputs baffle me somewhat. Has anyone any pointers for me? All I want to do is copy the build spec. from one project to another. Searches have revealed little. Regards, GGT. Hi Graeme I have posted example code here that you may want to look at to add files to a project etc... For your copying build spec question Cat tried to tackle it here. I had a really quick go to and kept corrupting the xml. I would be interested to know if you get it to go. Cheers -JG Quote Link to comment
Graeme Posted December 25, 2009 Author Report Share Posted December 25, 2009 Thanks for the replies so far. I'll investigate them over the holiday period and let you know how I get on. Regards. Quote Link to comment
Popular Post Graeme Posted January 1, 2010 Author Popular Post Report Share Posted January 1, 2010 Happy New Year everyone, Well after much trying over the holiday period I've come up with the attached. Very much an experimental work in progress, although it does provide the functionality I was seeking. I couldn't see any posted LV code as I don't have 2009 yet (company has lost the discs!!!), but clues you all gave me in the text of your replies, and in a similar one mesmith relied to elsewhere, gave me enough to think on for myself. There are issues, though. GUIDs are a problem; see the comments in the AppEXEConfig subVI. Also, in the same subVI it would nice to create a custom control that contained a tag name and tag value. You'll know what I mean when you investigate it. I should add, by way of a disclaimer, I don't do much with projects generally. I only use them to create executables (hence my interest in this area) from a single top level VI, so if my goals seem limited project-wise then that's why. I'm not involved with large multi-developer projects at all. Constructive criticism is very welcome. Graeme. AppEXEConfig.vi ProjectMaker.vi 4 Quote Link to comment
PJM_labview Posted January 4, 2010 Report Share Posted January 4, 2010 Graeme, That "AppEXEConfig.vi" is pretty cool and interesting. I learned something. Thanks PJM Quote Link to comment
KoBe Posted January 21, 2010 Report Share Posted January 21, 2010 Hi @ all! I have a similar challence. Additionally i would like to include cRIO targets programmatically into the project structure. The type of the cRIO, chassis and modules is given and should be programmatically added to the project. A played arround several hours, but I didn't find out how to add an other target beside the "My computer". The reason is that i didn't find documentation about class name, type, reference and so on of embedded target. Could anyone help me please? Thank you Quote Link to comment
w15nu Posted June 7, 2010 Report Share Posted June 7, 2010 Happy New Year everyone, Well after much trying over the holiday period I've come up with the attached. Very much an experimental work in progress, although it does provide the functionality I was seeking. I couldn't see any posted LV code as I don't have 2009 yet (company has lost the discs!!!), but clues you all gave me in the text of your replies, and in a similar one mesmith relied to elsewhere, gave me enough to think on for myself. There are issues, though. GUIDs are a problem; see the comments in the AppEXEConfig subVI. Also, in the same subVI it would nice to create a custom control that contained a tag name and tag value. You'll know what I mean when you investigate it. I should add, by way of a disclaimer, I don't do much with projects generally. I only use them to create executables (hence my interest in this area) from a single top level VI, so if my goals seem limited project-wise then that's why. I'm not involved with large multi-developer projects at all. Constructive criticism is very welcome. Graeme. Hi Grame, Thanks a lot for your examples. It helps me by A LOT! I am not sure your version of LabVIEW, but when I tried it in LV 2009 and I build/run the EXE generated, it give me error: LabVIEW: File is not a resource file. The file <filename> could not be loaded So I did a troubleshooting and found the culprit was one of the TAG Name (in AppEXEConfig.vi), Source[1].newName with value of <filename>.exe. The solution to this problem: - Remove the element: Source[1].newName - Or change the extension to .vi instead of .exe I hope it helps to someone who using it in LV 2009 Cheers, w15nu Quote Link to comment
Graeme Posted August 11, 2010 Author Report Share Posted August 11, 2010 Hi w15nu, Haven't looked at this for a while but thanks for your input, I'll look into it. I'm running 8.6 (IT department's a bit slow) and that's what the code was written in. Annoying that it breaks just one major revision later, although, as the code's comments state, no guarantees. I'll probably skip 2009 and go to 2010 when the disks arrive in a few weeks, so I'll try it with that. Regards. Quote Link to comment
jgcode Posted August 11, 2010 Report Share Posted August 11, 2010 Haven't looked at this for a while but thanks for your input, I'll look into it. I'm running 8.6 (IT department's a bit slow) and that's what the code was written in. Annoying that it breaks just one major revision later, I too, I find the project tags can change a lot between versions, making supporting multiple version of LabVIEW very difficult. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.