Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Drawing Automation

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
mcloughlin_b
804 Views, 5 Replies

Drawing Automation

Hi boffins

 

I have cobbled up some code to export drawings (parts only with criteria) from an assembly (from an earlier post).

I am trying to achieve the following:

  • get a list of all parts in the drawing that match some criteria
  • sort this list
  • trim the list down to a maximum number of parts (i only want 20 sheets per drawing)
  • then export the remaining parts in the list to a defined drawing template.

the idea is that i will tag each exported part on export such that it does not appear in the list when rerun

 

Code thus far attached below

 

Cheers and thanks in advance for any ideas / suggestions

5 REPLIES 5
Message 2 of 6
A.Acheson
in reply to: mcloughlin_b

Hi @mcloughlin_b 

I haven't tested this just reading the text file. 

Could you indicate what the code is doing and not doing at the moment? I see one item the arraylist. It is declared in the main sub but not passed through to other subs so isn't available to be used later. Your using a class so it can be declared out side the main sub. The main sub is trying to switch the object collection which I've never seen before. Usually you would have a seperate loop of each object collection and a boolean or trigger statement  to start the loop. 

 

For the max 20 files per drawing you just need a counter in the documents loop and likely a seperate sub for drawing creation and saving to allow you to call a new drawing at the >20 mark. 

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 3 of 6
mcloughlin_b
in reply to: A.Acheson

hi Alan

 yes its a bit of a mess at the moment, works but is needing some tidying up.

 

I had thought of using a counter to limit the output but am really puzzling over how to sort my list prior to export so that the drawings can be created in sequence. This is where i thought i could create an arraylist of parts matching my criteria and then sort the list prior to export. can't seem to get this to work but perhaps its because i am trying to switch the object collection from the main sub. 

i will press on and see if i can nut this out, maybe rework the code a bit.

Any ideas how I can get to a sorted list are appreciated.

 

regards,

 

bryan

Message 4 of 6
A.Acheson
in reply to: mcloughlin_b

You can sort an arraylist or list of string using the sort method. 

List.Sort

 

Steps to take

1. Loop through documents and add either filename, part number etc

2. List.Sort.

3.Use nested loop to run through count of arraylist which will do two things. Count for your drawing counter and index in order each item in the list. Second loop to run through documents loop looking for matching arraylist criteria. 

4. Carry out an action on matching criteria.

 

 

 

 

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 5 of 6
A.Acheson
in reply to: A.Acheson

Here is a quick sample of the steps.  

Dim AsmDoc As AssemblyDocument = ThisDoc.Document

Dim FileList as New List (Of String)
For Each RefDoc As Document In AsmDoc.AllReferencedDocuments  Then 
   Dim RefFileName As String = IO.Path.GetFileNameWithoutExtension(RefDoc.FullFileName)

		Logger.Info("RefFileName: " & RefFileName)
		Logger.Info("Part Number: " & RefDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value ) 
  FileList.Add(RefDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value )	
Logger.Info("Description: " & RefDoc.PropertySets.Item("Design Tracking Properties").Item("Description").Value )
		Logger.Info("Title: " & RefDoc.PropertySets.Item("Inventor Summary Information").Item("Title").Value)		
Next 


For i = 1 As Integer to FileList.Count
  For Each RefDoc As Document In AsmDoc.AllReferencedDocuments 
   
   If Filelist.Item(i) = RefDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value Then

'Call sub routine and use pass RefDoc
   End If 
  Next
Next
 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 6 of 6
mcloughlin_b
in reply to: A.Acheson

Hi Alan

Apologies for the delayed reply, have been away for a while.

Thanks for this, I will press on and see if I can cobble something together.

 

I will let you know how this goes.

 

Cheers

 

Bryan

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report