Hey Zipit!
Thanks for the response, I actually completely overlooked the fact that I had to convert it to a string......(insert hammer on head here)
Note to self hahaha!
Stay safe out there!
Cheers!
MattG
Hey Zipit!
Thanks for the response, I actually completely overlooked the fact that I had to convert it to a string......(insert hammer on head here)
Note to self hahaha!
Stay safe out there!
Cheers!
MattG
Hey Y'all,
I'm running into an issue with a JSON encoding bit, I'm getting a type error of this
TypeError: unable to convert unicode to @net.maxon.interface.url-C
I am trying to read a JSON file into cinema and make it a path in the plugin, below is the current code I have
#----------------------------------------------------------------------------------------------------------------------------------------
# IMPORT OBJECTS
#----------------------------------------------------------------------------------------------------------------------------------------
import os
from os import listdir
from os.path import isfile, join
def import_objs(OBJ_LIST):
global SETTINGS
LIBPATH = SETTINGS["SETTING_ASSET_LIBRARY_FULLPATH"]
FILES = [f for f in listdir(LIBPATH) if isfile(join(LIBPATH, f))]
for OBJ in OBJ_LIST:
OBJ_FILENAME = OBJ[0] + ".c4d"
if OBJ_FILENAME in FILES:
FILEPATH = os.path.join(LIBPATH,OBJ_FILENAME)
c4d.documents.MergeDocument(doc, FILEPATH, c4d.SCENEFILTER_OBJECTS | c4d.SCENEFILTER_MATERIALS, None)
c4d.EventAdd()
return True
Any thoughts?
Cheers!
MattG
Well Uh.....Yea.....Guess I should take a break......Thanks for the point out of the lower case b........
This is solved. Thanks Plugin Student!
Cheers!
MattG
Hey Guys,
I'm getting the error " AttributeError: 'GUI' object has no attribute 'AddCheckBox' " in my console, and I believe I'm bringing in the right libraries, I think...But, I cannot seem to find anything that's helping searching through forums and the c4d.gui info pages.
Maxime helped me understand the group concepts so thanks again for that. I commented out a lot of code to test things, but here's the current code that's throwing the error. Still a lot of learning to do, but I've been on this particular error for 2 hours now....oh fun haha
import c4d
from c4d import gui, plugins, bitmaps, documents
class GUI(gui.GeDialog):
""" Creates the main graphical user interface of the plug-in """
ResourceFileGroup = 101
SettingFilegroup = 102
Label_Folders = 201
Label_Settings = 202
Label_ObjectsImport = 203
ResourceFolder = 301
MVRFileLocation = 302
AllCheckBox = 401
HangingPosCheckBox = 402
TrussCheckBox = 403
FixturesCheckBox = 404
GeometriesCheckBox = 405
ComboBox_ID = 1003
AddChild_1 = 1004
TextEdit = 1005
RadioGroup = 1006
RadioText = 1007
RadioChild = 1008
def CreateLayout(self):
self.SetTitle("My Dialog")
self.GroupBegin(self.ResourceFileGroup, 0 | 0)
self.AddStaticText(self.TextEdit, c4d.BFH_SCALEFIT | c4d.BFV_TOP, 100, 25, "Source Files", 1)
self.AddButton(self.ResourceFolder, c4d.BFH_LEFT | c4d.BFV_TOP, 125, 25, "Resource Folder")
self.AddButton(self.MVRFileLocation, c4d.BFH_LEFT | c4d.BFV_TOP, 125, 25, "MVR File")
self.GroupEnd()
self.GroupBegin(self.ResourceFileGroup, 0 | 0)
self.AddStaticText(self.TextEdit, c4d.BFH_SCALEFIT | c4d.BFV_TOP, 100, 25, "Settings", 1)
self.AddCheckBox(self.AllCheckBox, c4d.BFH_LEFT | c4d.BFV_TOP, 125, 25, "All")
self.GroupEnd()
# if self.GroupBegin(self.SettingFilegroup, 0 | 0):
# self.AddStaticText(self.TextEdit, 0 | 0, 100, 25, "Settings", 1)
# self.AddCheckBox(self.AllCheckBox, c4d.BFH_LEFT | c4d.BFV_TOP, 125, 25, "All")
# self.GroupEnd()
# self.SetTitle("CAV MVR IMPORTER") # Set dialog title
# self.AddRadioText(self.Label_Folders, c4d.BFH_LEFT | c4d.BFV_TOP, 0, 0, "Source Files")
# self.AddRadioText(self.Label_Settings, c4d.BFH_CENTER, 0, 0, "Settings")
# self.AddRadioText(self.Label_Settings, c4d.BFH_RIGHT, 0, 0, "Objects To Import")
# self.AddButton(self.ResourceFolder, c4d.BFH_LEFT | c4d.BFV_TOP, 125, 25, "Resource Folder")
# self.AddButton(self.MVRFileLocation, c4d.BFH_LEFT | c4d.BFV_TOP, 125, 25, "MVR File")
# self.AddComboBox(self.ComboBox_ID, 0 | 0, 100, 25, True, True)
# self.AddChild(self.ComboBox_ID, self.AddChild_1, "Drop Down 1")
# self.AddRadioGroup(self.RadioGroup, c4d.BFH_SCALE | c4d.BFV_SCALE, 1, 3)
# Create a Group, its usefull because here we adds the StaticText Gadget and to make it appears again
# LayoutChanged needs to be called, which work only a group.
# if self.GroupBegin(self.TextEditGroup, c4d.BFH_SCALEFIT | c4d.BFV_TOP):
# self.AddStaticText(self.TextEdit, c4d.BFH_SCALEFIT | c4d.BFV_TOP, 100, 25, "", 1)
# self.HideElement(self.TextEdit, True)
# self.GroupEnd()
# def Command(self, id, msg):
# # RESOURCE FOLDER BUTTON
# if id == 201:
# fn_ResourceFolder = c4d.storage.LoadDialog()
# # Unhides the Text element
# self.HideElement(self.TextEdit, False)
# # Checks if its a str, then display the file path
# if isinstance(fn, str):
# # Unhides the Text element
# self.HideElement(self.TextEdit, False)
# # SET THE STRING
# self.SetString(self.TextEdit, fn)
# # If its not a string, the user cancelled
# else:
# self.SetString(self.TextEdit, "User cancelled")
# # Notify the layout of the group changed, this will invalidate the group and it will be then redraw
# # This is needed because the UI was hidden, if the Ui is not hidden then there is no need for it
# self.LayoutChanged(self.TextEditGroup)
# # MVR FILE BUTTON
# if id == 202:
# fn_MVRFileLocation = c4d.storage.LoadDialog()
# # Unhides the Text element
# self.HideElement(self.TextEdit, False)
# # Checks if its a str, then display the file path
# if isinstance(fn, str):
# # Unhides the Text element
# self.HideElement(self.TextEdit, False)
# # SET THE STRING
# self.SetString(self.TextEdit, fn)
# # If its not a string, the user cancelled
# else:
# self.SetString(self.TextEdit, "User cancelled")
# # Notify the layout of the group changed, this will invalidate the group and it will be then redraw
# # This is needed because the UI was hidden, if the Ui is not hidden then there is no need for it
# self.LayoutChanged(self.TextEditGroup)
# print fn_MVRFileLocation
def main():
# Test dialog
diag = GUI()
diag.Open(dlgtype=c4d.DLG_TYPE_MODAL, defaultw=1000, defaulth=400)
# Execute main()
if __name__ == '__main__':
main()
Thanks again for any insight.
Cheers!
MattG
Thanks Maxime, understood on the rules and regulations, sorry about that.
I understand the group concept now, read up more on it and I have a better idea on how to approach the goal I'm trying to get to.
I have another error I'm getting but I'll try to do another post and see if I tag it right!
Thanks for your time!
Cheers!
MattG
AddStaticText Insert String defined by variable as text name in Python
Hey guys,
I'm having a hard time trying to figure out the right order in which I'm trying to use a string obtained by a variable andu use the string infomation as a StaticText. Here's my current working code minus the AddStaticText part which works under the CreateLayout Definition, but it would run that before obtaining the information I would want it to, so I moved it under my Command Definition. Any small insight would be very grateful!
import c4d
from c4d import gui, plugins, bitmaps, documents
class GUI(gui.GeDialog):
""" Creates the main graphical user interface of the plug-in """
BUTTON_ID = 1001
Checkbox_ID = 1002
ComboBox_ID = 1003
AddChild_1 = 1004
TextEdit = 1005
def CreateLayout(self):
self.SetTitle("CAV MVR IMPORTER") # Set dialog title
self.AddButton(self.BUTTON_ID, c4d.BFH_LEFT | c4d.BFV_TOP, 100, 25, "Close Dialog")
self.AddCheckbox(self.Checkbox_ID, c4d.BFH_LEFT | c4d.BFV_TOP, 25, 25, "Checkbox")
self.AddComboBox(self.ComboBox_ID, 0 | 0, 100, 25, True, True)
self.AddChild(self.ComboBox_ID, self.AddChild_1, "Drop Down 1")
#self.AddStaticText(self.TextEdit, 0 | 0, 100, 25, "Test Text", 1)
def Command(self, id, msg):
if id == 1001:
fn = c4d.storage.LoadDialog()
print fn
if fn == str:
self.AddStaticText(self.TextEdit, 0 | 0, 100, 25, fn, 1)
def main():
# Test dialog
diag = GUI()
diag.Open(dlgtype=c4d.DLG_TYPE_MODAL, defaultw=1000, defaulth=400)
# Execute main()
if __name__ == '__main__':
main()
Cheers!
MattG
Hey Richard!
Thank you for the response, I have VS2017 version 15.9 all set up now, I think..... haha. I can see all the solutions in VS as well, but I ran the powersheel commands without having 2017 installed and I could see them in 2019, do I need to re-run the command or is it on the compile side that 2017 is the right version?
I've been reading through all that documentation and I have seen the resources on Git as well so thanks for helping me understand I'm looking in the right spots haha! Thanks for the help so far, I'm sure I'll be back soon with more questions haha!
Cheers!
MattG
Thanks for the replies guys! For VS2017, do I need version 15 or 15.9?
Thanks for the introduction page Plugin Student! I'll look over those again to see if there's anything that I'm not really understanding!
So, quick update, I found a blog to help go through the initial process, which I was doing TOTALLY wrong, which gave me the solutions file for VS. https://vonpb.de/blog/cinema-4d-c-plugins-getting-started/
From what I understand this is where I source the right header files needed for what I'm looking for. Hopefully I'm in the right direction.
Hey Everyone,
I hope y'all are doing well. I've been trying to learn how start my first plugin which I want to make superbasic for a starter project, I have taken classes on C++ but I will not say I'm an experienced programmer by any means. The goal is to insert a cube and give it dedicated coordinates from a CSV file. I believe I have found all the functions that I need to make this happen minues some C++ functions, but my quesiton is, are there certain libs that I need to include in my header file? Also, plugin's from what I'm seeing are uncompiled lines of code...? Maybe? I see a lot of c4d_resource.h files in example files, I see a lot of c4d_plugin.h files, so I guess I'm trying to make sure I have the bare libs needed to pull from the SDK.
Any insight would be more than great, but thank you for your time and I'm looking forward to learning more about this!
Cheers!
MattG
Hey Guys!
I think I figured it out! Will resoond if there's any questions!
Cheers!
MattG
Hey My Friend!
Thank you for the response. So, thinking I understood this, I'm able to change the value within the console, but am still getting an error on the line with that syntax inside the script, I'm sure I'm missing something, I'm gonna re-trace my steps here. What I'm trying to do overall goes back to my first post about the OSC thing, so my thinking is figure out how change the value in a UserData Field on a specified piece of mesh, and then assign a variable to listen to the OSC integer, once I cross that bridge haha, but this is where I believe I shoudl start....I think...haha. Here's a screenshot showing my findings.
Thanks again for your time Maxime!
Cheers!
MattG
Hey Everyone,
I hope this finds everyone well. I'm trying my best to learn about the interaction of UserData on objects with a very basic understanding of python(if that haha), I was reading this thread and playing around with it: https://developers.maxon.net/forum/topic/11467/access-custom-user-data-by-name-not-by-id
and I'm now trying to figure out what functions to call to update the UserData without having to delete the UserData, edit the value then execute the script again. My guess is to use the SetUserDataContainer.
I attached what my best guess is right now, gonna keep messing and researching the forums.
Thanks for your time!
Cheers!
MattG
Hey Guys!
Thank you very much for the insight! All of this makes sense, it helps me understand a little more about how the node part works! I really appreciate the time on this and thanks again for the help! I hope y'all are doing well!
Cheers!
MattG
Hey Everyone,
I was wondering what might be easier to acheive a very "simple" task I'm trying to accomplish. I'm trying to grab a single OSC message from an external program (touchdesigner) and bring it into C4D to control a slider I built for an object. Is utilizing the xpresso tag python script easier or does OSC not exist in that node? Appologies if this is a redundent question, still researching the best I can. Thank you for your time!
Cheers!
MattG