On 10/04/2017 at 14:33, xxxxxxxx wrote:
Hi guys,
I am trying to Load the data from the text file, read it and load it in to the link box. but it don't link what I tell it to find in the object manger, which is Cube.1 inside the .txt file. Plz tell what I am doing wrong in my code.
This is what inside the .txt file.
Cube.1
The Code:
Load = {"id": 1009, "name": "Open Settings"}
SaveSettingsPath_in_field = 1011
UI_TEMP_S1 = 1010
class LinkBoxDialog(gui.GeDialog) :
def CreateLayout(self) :
self.MenuFlushAll()
self.MenuSubBegin("Settings")
self.MenuAddString(Load["id"], Load["name"])
self.MenuSubEnd()
self.MenuFinished()
self.GroupBegin(34, c4d.BFH_MASK, rows=1)
self.AddStaticText(203, c4d.BFH_CENTER, 0, 0, "Settings")
self.Enable(203, False)
self.AddEditText(SaveSettingsPath_in_field, c4d.BFH_MASK, 250, 10)
self.GroupEnd()
self.GroupBegin(34, c4d.BFH_MASK, rows=1)
self.AddStaticText(0, c4d.BFH_CENTER, 0, 0, "TEMP 1.")
self.rootLinkBaseContainer = c4d.BaseContainer()
self.LinkBox1 = self.AddCustomGui(UI_TEMP_S1, c4d.CUSTOMGUI_LINKBOX, "", c4d.BFH_CENTER, 250, 10, self.rootLinkBaseContainer)
self.GroupEnd()
return True
def LoadSettings(self) :
doc = c4d.documents.GetActiveDocument()
Load_Path = st.LoadDialog(type=c4d.FILESELECTTYPE_ANYTHING, title="Open Your Settings Folder Directory.", flags=c4d.FILESELECT_DIRECTORY, force_suffix=".txt")
self.SetString(SaveSettingsPath_in_field, Load_Path)
Get_Path = self.GetString(SaveSettingsPath_in_field)
doc = c4d.documents.GetActiveDocument()
linkBox = self.FindCustomGui(UI_TEMP_S1, c4d.CUSTOMGUI_LINKBOX)
data1 = open(os.path.join(Get_Path, 'Temp_Data_1.txt'), "r")
read_txt = data1.readline()
get_obj = doc.SearchObject(read_txt)
linkBox.SetLink(get_obj)
c4d.EventAdd()
return True
def Command(self, id, msg=None) :
if (id == 1009) :
self.LoadSettings()
return True
plz help or tips would be really helpful to me.
Cheers,
Ashton