Jump to content

Programmatically build new project problem


Graeme

Recommended Posts

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.

Link to comment

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

Link to comment

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 by RyanPodsim
Link to comment

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

Link to comment
  • 3 weeks later...

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

Link to comment
  • 4 months later...

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

Link to comment
  • 2 months later...

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.

Link to comment

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. frusty.gif

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.