This content has been marked as final. Show 29 replies
I'm working on this too, but only found PDM 2009 BOM's API and no example. If anyone has examples please share!
Attached is a simple solution I created. It should give you a basic understanding on how to read the BOMS. To be honest, this was my first attempt, and while it works, the code may need to be cleaned up a bit. I just whipped this up today to mess around with the BOM methods.
Let me know if you have any questions.
EPDMBomExample.zip 163.1 KB
Thank-You soooooo much Lee for taking the time to do that!
I can't open it though... I have Visual Studio 2005 and it says it was created with a newer version... any chance you could save it off where it's compatible with 2005?
Sure, see attached.
In the app, click the button beside the filename and choose an assembly that has named BOMs saved. Then click the 'Get boms' button.
Very Very Nice interface!!! My IT department is in the process of upgrading our PDM system today, so I can't test it out right now... but I will as soon as they're done.
THANK-YOU THANK-YOU Again!!!
I've got several things I've got to do with BOM functions, so I'll make sure to post my code up here when I've got something that works.
Ok.. they're finally done with our upgrade and I was testing out your program...
I created a custom BOM in the admin called AutoPlot and when I run the program it logs me into the vault just fine, but when I tried to retrieve the BOM it says "0 BOMs found."
Any idea what might be causing that?
Hi Christine -
You need to create a named BOM. So, when you are on the BOM tab of an assembly, do a save as - give the file a name - create a couple so you'll have more than one result.
Were you suggesting that because that's how Lee's program is set up, or is that the only way to use the BOM features is with a Named BOM?
I was really really hoping to be able to do it to where the users don't have to go through and save out the BOM first.
Thanks again for all your help Joy and Lee!!!!!
The BOM interface is only for named BOMs. It's the only option; how would one manage a computed BOM?
 Actually, there should be an AddBOM() method, but I don't see one. [/edit]
It seems like that since the information is there for computed BOM's that you'd be able to retrieve it... if you can't work with computed BOMs... what is this part in the API help file for:
This method returns an interface of a computed bill of materials.
If you have to save out a named BOM to be able to work with it via the API, that's really not much better than just saving out a CSV file and working with that, and it wouldn't have needed any extra API controlls to do it with.
Sorry... still an awesome program... and thank-you sooooo much for taking the time to make it... it's a really great example.. I'm just not sure how I'm going to do what I need to do if I can't work with computed BOMs... kind a bubble-burster... lol
You're right and I missed that. Sorry. So you should be able to work with computed BOMs.
Try working with the example gy calling GetComputedBOM instead of GetDerivedBOMs. I'm not sure you'll be able to call Commit(), but it's worth a try. Like I said, that was my first attempt, so I don't have a lot of experience with these interfaces. At any rate, you're welcome.
I'll play around with it... I finally found the part in your code that had the GetDerivedBoms so I'll see what I can do with tweaking that bit. Am I the only one that has major issues converting this:
HRESULT GetComputedBOM( [in] VARIANT oBomLayoutNameOrID,
[in] long lVersionNo,
[in] BSTR bsConfiguration,
[in] long lEdmBomFlags,
[out,retval] IEdmBomView **ppoRetView );
Into usable code???? It's like a whole other language that I've missed the translation guide on... lol
I'll post what I get up on here if I can make it work.
And no worries... 2009 that has these interfaces just came out, the only ones with experience with it are the ones that made it.. lol.. and they obviously didn't feel like making examples, or they'd be in the API help file.
Now.... let's see if I can tweak it into submission.... he he he
I'll see what I can do about tweaking my example to give you something to go by. Stand by.
You are AWESOME!!!! Thank-You Thank-You Thank-You!!!!!!!!!!
I've been messing with it and I can't get it to stop erring out... but then again... I'm just starting to get the hang of VB.NET and this is written in C#... so that's making it a tad bit more confusing... lol...
Look like I need to be adding a new coding language to my list of ones to learn... man... that list is getting longer and longer by the day...
OMGosh!!! You are my hero!!! Awesome!!! (There needs to be a jumping up and down smiley here... but... )
This has got to be the best example of how to use the BOM interface... it looks like you might have used almost every command available except for just a couple of them.
One quick question though... I noticed that you're using C#... is there any advantage to using that instead of VB.NET or just a personal preference?
Thank you again for all your help with this... I truly can't thank you enough... you've saved me hours of pulling my hair out trying to figure out how to structure and use these commands!!
This is still such a useful program!
I'm trying to get it to work with Weldment Cut List BOMs now... and it doesn't seem to want to read those. Does anyone know if that can be done in EPDM 2011?
You're welcome Christina. Hopefully others can benefit from the example.
I prefer C# over VB.NET mainly because of the syntax. There aren't any real advantages of one language over the other IMO as it all targets the same framework in the end.
The fact that this topic has already had 98 views means that there are probably more people other than me that have already benefited from it. It's good to have an actual working program to look at as a reference when you're learning to do something and even better when there are no examples at all in the help file.
Thank-You for sharing your opinion of C# vs VB.NET as well... I'm coming from web programming, so application programming and it's structure is still very new to me. I was noticing that the syntax seemed a bit more simplified with your program vs. the VB.NET programs... but it looks like the project structure is the same.
Thank-You again soooo much for your help!!
I think that we can consider this question answered - Lee's program is a very good example of using the API to access the BOM's - both computed and named.
Ok... of course I would have another question... lol...
When I'm looking at the BOM in PDM, I have the option to see only the Top-Level items in the BOM... but I'm not seeing that option in the API help files anywhere.
Is there a way to restrict to the BOM that you get through the API to only Top-Level just like what you see when you're in the vault?
hmmmmm... would this have anything to do with whether or not something is a top-level item:
This method returns the cell's tree level. (This is applicable for computed BOMs.)
Geez.. you'd think if they couldn't include examples, they could at least give better descriptions of what it does... (sigh)
The treeLevel will give you what you need. Level 1 is the root, level 2 is the first indent and so on...
Thank-You for clearing that up for me Lee!!!!
Has anyone seen anything that would tell you what the parent Assembly is... like if I have:
and I want to know that the Parent Assembly of Part 5 is Assembly 3, the Parent Assembly of Assembly 3 is Assembly 1... etc etc.
When you loop through the rows, your assemblies and parts are returned in reverse order. So, your parent assembly will be the file you choose (obviously) and then the parts are returned followed by the sub-assemblies.
Given your example you would end up with the following;
Part 5 (2)
Part 4 (2)
Assembly 3 (1)
Part 3 (2)
Part 1 (2)
Assembly 2 (1)
Where (#) is the level.
If you were looking for a what assembly are part belongs to, you would loop through until you found the part, and then keep looping until you find the next assembly whose level is one less than the part.
For example, say I have the following structure [level in ()]:
Assembly 1 (0)
--> Assembly 2 (1)
----> Part 1 (2)
----> Part 2 (2)
----> Assembly 3 (2)
--------> Part 3 (3)
--------> Part 4 (3)
If I wanted to find what assembly Part 2 is in, I would look for the next assembly after the part whose level is 1.
Oh my gosh... that makes perfect sense... !!! I didn't realize that it returned it in the reverse order.... that actually makes that a little simpler.
It would be nice if they would include a command to return the parent assembly.. but this looks like it would work!! I've been going crazy all morning trying to find a way to make that work knowing the levels.
You are my hero!!
Way to go Lee! Thanks for taking the time on this one!
Christina, you are missing what would be nice...it would be nice if the API had an object written for us to do this! I say we storm the enhancement request castle's gates!
I know it... Lee has been just awesome with this question.. I'm sure that I'm not the only one benefiting from it either, it's had a lot of views.
Now if I can just get my little program to quit crashing PDM I'll be in business... lol... but at least it's coming along thanks to Lee's wonderful examples!!! I'll post it up here if/when I get it working so we've got another example.
And I totally agree... It would be very very nice if they an object written to do this... sometimes I wonder if the people that write any of these programs (PDM, SolidWorks, etc...) actually use them ever... lol
Guys, help please) How can i get only part?