Message 1 of 3

Not applicable
12-07-2020
05:55 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello!
I am attempting to adapt a script that turns off adaptivity for all parts and sub-assemblies (and their parts) to only turn off adaptivity for parts directly in the active assembly (and not sub-assemblies and their parts). This is the first script, which works as expected and turns off adaptivity for all parts and subassemblies at all levels:
'checks if active document is an assembly
dim doc as Document = ThisApplication.ActiveDocument
if doc.DocumentType <> kAssemblyDocumentObject then
MessageBox.Show("This document is not an assembly. This script can only be used on an assembly.", "Oops...")
return
end if
'iterates through each file and turns off adaptivity for all adaptive files
dim i as integer = 0
for each oDoc as Document in doc.AllReferencedDocuments
try
if oDoc.ModelingSettings.AdaptivelyUsedInAssembly = true then
oDoc.ModelingSettings.AdaptivelyUsedInAssembly = false
i += 1
end if
catch
end try
next
MessageBox.Show("Adaptivity was turned off for " & i & " file(s).", "Success!")
And this is my attempt to run this rule only on parts files directly in the active assembly:
'checks if active document is an assembly
dim doc as Document = ThisApplication.ActiveDocument
if doc.DocumentType <> kAssemblyDocumentObject then
MessageBox.Show("This document is not an assembly. This script can only be used on an assembly.", "Oops...")
return
end if
'iterates through each file in the active document and turns off adaptivity for all adaptive files
dim i as integer = 0
for each oDoc as Document in doc.AllReferencedDocuments
Try
If oDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject and oDoc.ModelingSettings.AdaptivelyUsedInAssembly = True Then
oDoc.ModelingSettings.AdaptivelyUsedInAssembly = false
i += 1
end if
catch
end try
next
MessageBox.Show("Adaptivity was turned off for " & i & " file(s).", "Success!")
Unfortunately, the second script seems to behave identically to the first script and I'm not sure why. Any help?
Solved! Go to Solution.