Showing results for 
Search instead for 
Did you mean: 

Template update on drafts: Copy-Paste ParstList


Hi there guys.


I'm polishing an interesting app in order to batch-update drafts templates. In a nutshell, it copies each sheet content and pastes it on the new template, saving and giving format to differente elements, snapping stuff to background margins or title block, styling texts and views, applying new presets to PartsLists, managing ModelLinks and some other stuff.


I think something like this should be built inside Solid Edge. When you need to update thousands of Drafts with a new title block (in our case, in order to add a codebar), background sheet or styles...


All works fine, but copying and pasting PartsLists gets somewhat limited. When you have done some editing on the original PartLists (for example, excluding some elements), those changes get lost when pasting.




The problems is that, as far as I have seen, I have no way of getting access to the exclusion state of components in a particular PartList (the tree shown in the image) in order to read that info in the original and apply to the pasted instance. I can only get the general ModelLink and ModelNodes of the draft upon which the partList is built, but none of the particular exclusions done on it on a particular PartList.


The fun fact is that copying and pasting manually works fine, the PartList contains all it's particular options, which are retained even if I apply a new preset setting on the PartList. So, it seems that copying and pasting from the API works differently.


Currently, I simply add the PartList in the SelectionSet, Copy() and Paste() in the new Sheet. Not sure if there's a better method. Interesting note: the CopyToClipboard() Method of the PartsList object does not seem to work...


As an example, when the PartsList is linked to a configuration on the assembly, I can read that information on the original and apply it on the copy, since that info is also "lost" when Copy-Pasting, even when the destination draft contains the same ModelLink. Ugly but works fine, so I would like to do the same with manual Exclusions.


Any clues about duplicating PartsLists, or getting access to the detailed configuration on them? Even better, a decent way of duplicating the PartsList?


As always, thanks in advance. Could't imagine my workflow without the help of this forum.


Re: Template update on drafts: Copy-Paste ParstList


After further analysis I have discovered some issues.


Inside a PartsList object, the ModelLink.ModelNodes collection allows me to inspect exclusion of componets regarding that PartsLists, by means of the property:




Since copy-pasting a PartList seems to "clean" all those flags, I can copy them again after pasting, in order to get the same result. Something like this:


For i As Integer = 1 to objNewPL.ModelLink.ModelNodes.Count
  objNewPL.ModelLink.ModelNodes.Item(i).IncludeInPartsList = objOldPL.ModelLink.ModelNodes.Item(i).IncludeInPartsList

However, the weird thing is that the code works and copies all flags, but the new PartList is not correctly updated, and that info is not reflected when inspecting it in SolidEdge, not trough the code.


So the new and the old PartsList don't match number of rows or components' quentities, which is the goal.


When you have more than one PartList in the same draft or sheet the thing is even worse, maybe just one of them is correctly updted, but without a clear pattern of how does the API work here...


Anyone has some clue? Thanks in advance!