Copy Partlist to to active sheet and position

Copy Partlist to to active sheet and position

NachoShaw
Advisor Advisor
537 Views
4 Replies
Message 1 of 5

Copy Partlist to to active sheet and position

NachoShaw
Advisor
Advisor

Hey

 

I have done this before but i cant find my code (was done at a company that i am no longer part of)...

 

I need to do the following:

 

  • Copy partlist from a sheet called BOM. I have set the sheet number at the time of generation which at this stage is sheet number 6
  • paste partslist into active sheet
  • change its style from 'BOM-ALL' to 'BOM-CNC'
  • position the partslist to the top left of the sheet border
  • turn off all rows ( i can do this)
  • turn on the row that matches the current part on the sheet (i can do this)

alternatively

would it work if i set a public member as a PartsList that i set up and then for each sheet, add that partslist to the active sheet instead of copying?

 

any help appreciated as always 🙂

 

 

Thanks

 

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
538 Views
4 Replies
Replies (4)
Message 2 of 5

marcin_otręba
Advisor
Advisor

Try this:

 

Dim drw As DrawingDocument = ThisDoc.Document
Dim model As Document = drw.ReferencedDocuments.Item(1)
Dim oSheet As Sheet= drw.ActiveSheet
Dim oBorder As Border = oSheet.Border
Dim oPlacementPoint As Point2d
oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(oBorder.RangeBox.MinPoint.X,oBorder.RangeBox.MaxPoint.Y)
Dim prtl As PartsList = oSheet.PartsLists.Add(model, oPlacementPoint)
prtl.Position = ThisApplication.TransientGeometry.CreatePoint2d(oBorder.RangeBox.MinPoint.X + (prtl.RangeBox.MaxPoint.X-prtl.RangeBox.MinPoint.X),oBorder.RangeBox.MaxPoint.Y)
prtl.Style = drw.StylesManager.PartsListStyles.Item("BOM-CNC")

instead of copiyng i create new one. Idk if it suits you, if not i can make something to copy instead of placing.

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

Message 3 of 5

NachoShaw
Advisor
Advisor

Hi

 

Thanks for the reply. It looks like by making a new one, Design View Representation filtering is not accessible by code hence the copy / new. I would prefer to do new because the coding is more straight forward but it needs to be filtered to a specific View Rep..

 

Thanks

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
Message 4 of 5

marcin_otręba
Advisor
Advisor

hi,

 

to copy from  one sheet to another(it will copy active filtering):

Dim drw As DrawingDocument = ThisDoc.Document
Dim oSheet As Sheet= drw.Sheets.Item(2)
Dim prtl As PartsList = drw.ActiveSheet.PartsLists.Item(1)
Dim oselset As SelectSet = drw.SelectSet
oselset.Clear
oselset.Select(prtl)
ThisApplication.CommandManager.ControlDefinitions.Item("AppCopyCmd").Execute
oselset.Clear
oselset.Select(oSheet)
ThisApplication.CommandManager.ControlDefinitions.Item("AppPasteCmd").Execute

 

according to my knowledge it is not possible to filter partslist trough api.

You can open referencing model with desired designviewrep. and then iterating trough partslist rows you can check corresponding occurance visibility and hide/show it depending from result.

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

Message 5 of 5

robertast
Collaborator
Collaborator

I tried to redo the rule so that I could copy it from the Sheet1 parts list to the active Sheet. This works well if you run Sheet1 first and then any active sheet.

 

Dim drw As DrawingDocument = ThisDoc.Document
Dim oSheet2 As Sheet = drw.Sheets.Item(1)
Dim oSheet As Sheet = drw.ActiveSheet
Dim prtl As PartsList = oSheet2.PartsLists.Item(1)
Dim oselset As SelectSet = drw.SelectSet

oselset.Clear
oselset.Select(prtl)
ThisApplication.CommandManager.ControlDefinitions.Item("AppCopyCmd").Execute
oselset.Clear
oselset.Select(oSheet)
ThisApplication.CommandManager.ControlDefinitions.Item("AppPasteCmd").Execute

Maybe someone can fix it to work right away on the "active sheet"