Praca z konfiguracjami
Working with Configurations
Pokazuje, jak tworzyć konfiguracje części i nimi zarządzać.
# create a new partP = Part('Test')
# create a new configurationFoo = P.AddConfiguration('Foo')# it's already unlocked by default but this is how to unlock a configurationFoo.UnlockAll()# set a single lockFoo.SetLocks(LockTypes.SuppressNewFeatures)# set multiple locksFoo.SetLocks(LockTypes.SuppressNewFeatures | LockTypes.LockColorProperties)# activate the configurationFoo.Activate()
# create a new configuration using 'Foo' as a baseBar = P.AddConfiguration('Bar', 'Foo')# activate itBar.Activate()
# get access to the default configuration and apply all locks to itConfig1 = P.GetConfiguration('Config<1>')Config1.LockAll()
# show the name of the active configurationActiveConfig = P.GetActiveConfiguration()print 'Current active configuration is: %s' % ActiveConfig.Name
# show the total number of configurationsprint 'Total number of configurations: %d' % len(P.Configurations)
# show the name of the second configurationprint 'Second configuration is: %s' % P.Configurations[1].Name
# check if a couple of the confgurations are activeprint 'Is second configuration active? %s' % ('yes' if P.Configurations[1].IsActive == True else 'no')print 'Is configuration "Bar" active? %s' % ('yes' if Bar.IsActive == True else 'no')Oryginał: Working with Configurations