Copy iProperty based on File Name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all
Can I ask for a little help on this please. I can't work this out. taken me 2 days so far. Not even sure if it can be done.
I have been using the below code for a while now and it works perfect. (Thanks to MechMachineMan) I would now like to change it a little.
From my Top Level assembly I would like to send either the iProperty "Qty Required A" or "Qty Required B" to each sub assembly and part based on their file name.
If the file name of a Sub assembly or part is say "Board Assembly" or "Board Weldment" then all sub assemblies and parts of "Board Assembly" or "Board Weldment" are to read "Qty Required B". This assembly or part could be 2 or 3 deep in the top level assembly.
Anything else and it reads "Qty Required A"
Please let me know if I have not explained it well.
SyntaxEditor Code Snippet
Dim openDoc As Document openDoc = ThisDoc.Document If openDoc.DocumentType <> 12291 Then MsgBox("You must have a document open to run this rule!") Exit Sub End If Dim BatchQty As Double Try BatchQty = iProperties.Value("Custom", "Qty Required") Catch MsgBox("No 'Qty Required' iProp found in this doc" & vbLf & vbLf & "Aborting rule!") Exit Sub End Try Dim docFile As Document For Each docFile In openDoc.AllReferencedDocuments Dim docFName As String docFName = System.IO.Path.GetFileName(docFile.FullFileName) If docFile.IsModifiable = True Then Dim assemblyDef As AssemblyComponentDefinition assemblyDef = openDoc.ComponentDefinition Dim partQty As Double partQty = assemblyDef.Occurrences.AllReferencedOccurrences(docFile).Count Try oCheck = iProperties.Value(docFName, "Custom", "Qty Required") Catch iProperties.Value(docFName, "Custom", "Qty Required") = 0 End Try If partQty <> CDbl(iProperties.Value(docFName, "Custom", "Qty Required")) Then iProperties.Value(docFName, "Custom", "Qty Required") = partQty*BatchQty 'MessageBox.Show(docFName, "Title") End If End If Next