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:
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
Solved! Go to Solution.
Solved by A.Acheson. Go to Solution.
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.
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
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.
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
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.