[SOLVED] CLASS! Consol ERROR!
-
On 14/04/2017 at 19:51, xxxxxxxx wrote:
Correct me, please!
import c4d
class Brakers() :
"""docstring for Brakers"""
def __init__(self, nameCBD, nameCBI, nameCBC) :
#self.nameParent = nameParent
self.nameCBD = nameCBD
self.nameCBI = nameCBI
self.nameCBC = nameCBCdef CreateBrakerDisk(self) :
# добавляем ноль объект braker disc
nameCBD = c4d.BaseObject(5170)
nameCBD.SetName('eM ' + str(nameCBD)) # braker disc
doc.InsertObject(nameCBD)def CreateBrakerInstance(self) :
nameCBI = c4d.BaseObject(5126)
nameCBI.SetName('eM ' + str(nameCBI))
doc.InsertObject(nameCBI, nameCBD)def CreateBrakerConnector(self) :
# добавляем ноль объект wheel connector
nameCBC = c4d.BaseObject(180000011)
nameCBC.SetName('eM ' + str(nameCBC))
doc.InsertObject(nameCBC)def main() :
brakers_1_1 = Brakers(brakers_1_1, brakers_inst_1_1, brakers_connect_1_1)if __name__=='__main__':
main()
c4d.EventAdd()Concol ERROR:
Traceback (most recent call last) :
File "'scriptmanager'", line 34, in <module>
File "'scriptmanager'", line 30, in main
UnboundLocalError: local variable 'brakers_1_1' referenced before assignment -
On 14/04/2017 at 21:49, xxxxxxxx wrote:
I got it
import c4d
class Brakers() :
"""docstring for Brakers"""
def __init__(self) :
passdef CreateBrakerDisk(self) :
self.nameCBD = c4d.BaseObject(5170)
self.nameCBD.SetName('eM ' + str(self.nameCBD))
doc.InsertObject(self.nameCBD)def CreateBrakerInstance(self) :
self.nameCBI = c4d.BaseObject(5126)
self.nameCBI.SetName('eM ' + str(self.nameCBI))
doc.InsertObject(self.nameCBI, self.nameCBD)def CreateBrakerConnector(self) :
self.nameCBC = c4d.BaseObject(180000011)
self.nameCBC.SetName('eM ' + str(self.nameCBC))
doc.InsertObject(self.nameCBC)def main() :
brakers_1_1 = Brakers()
brakers_1_1.CreateBrakerDisk()
brakers_1_1.CreateBrakerInstance()
brakers_1_1.CreateBrakerConnector()if __name__=='__main__':
main()
c4d.EventAdd()But name of objects
eM <c4d.BaseObject object called 'Connector/Connector' with ID 180000011 at 0x000000000F572110>How rename it?
-
On 15/04/2017 at 03:10, xxxxxxxx wrote:
Hello for rename use SetName().
How I know it?
Simply go to the sdk. As you can read it's a c4d.BaseObject. So look at BaseObject class into the sdk.
https://developers.maxon.net/docs/py/2023_2/modules/c4d/C4DAtom/GeListNode/BaseList2D/BaseObject/index.html?highlight=baseobjectIn inheritance you can see C4d.BaseList2D. Then click on it. (since baseobject inherit from BaseList2D a BaseObject have all the function BaseList2D got)
And here you got SetName / GetName.
Hope it's help you
-
On 18/04/2017 at 01:21, xxxxxxxx wrote:
Thank you! There is an easier way!
def __init__(self, name = None, instance = 0, insertobject = None) :
self.name = name
self.instance = instance
self.insertobject = insertobject