Browsed by
Tag: assembly

List All Parts in an Assembly and Subassemblies

List All Parts in an Assembly and Subassemblies

Compatible with WizoScript versions: 2.01

Lists all the parts in an assembly and all of it’s sub-assemblies.

# list all the parts in an assembly and it's sub-assemblies
def ListPartsinAssembly(Assem):
  for P in Assem.Parts:
    print "%s in %s" % (P, Assem)
 
  for SA in Assem.SubAssemblies:
    ListPartsinAssembly(SA)
 
# top-level assembly
Assem = Assembly(r'C:\Users\Andy\Documents\JacktheRipperBot\Parts\Source', 'JacktheRipperBot.AD_ASM')
ListPartsinAssembly(Assem)
Assem.Close()
Find Parts and Assemblies in a Folder

Find Parts and Assemblies in a Folder

Compatible with WizoScript versions: 2.01

Gets a list of all parts and assemblies inside a folder and all sub-folders.

# get a list of parts and assemblies inside a folder and all
# sub-folders
 
import fnmatch
import os
 
# folder to search
Folder = r"C:\Users\Andy\Documents\Foldcopter\Parts"
 
# create empty lists
Parts = []
Assemblies = []
 
# perform the search
for Root, Dirnames, Filenames in os.walk(Folder):
  for Filename in fnmatch.filter(Filenames, '*.AD_PRT'):
    Parts.append(os.path.join(Root, Filename))
  for Filename in fnmatch.filter(Filenames, '*.AD_ASM'):
    Assemblies.append(os.path.join(Root, Filename))
 
# show all the files we have found
print Parts
print Assemblies