On 10/05/2017 at 19:53, xxxxxxxx wrote:
Hi,
The LoadString() function seems to only deal with the .str file found in the "strings_us" folder.
I don't think you can use it to get the items from the .str file in the "description" folder.
But I could be wrong. You'll have to get confirmation from the support guys about it next week.
To make things even more convoluted. It seems that you also need to use the c4d_symbols.h file to declare the item ID#s. Which most people do not use for Python plugins. Because it's not supported.
So if you're using an .h file in your description folder. Those ID's will need to be copied into the c4d_symbols.h file.
This makes the LoadString() function possibly not a great thing to use in Python.
In C++ we use the c4d_symbols.h file a lot. So it's usage is far less clumsy.
Here are my notes about using the LoadString() function in Python:
#LoadString() loads the resource items in the .str file in node based plugins
#IMPORTANT! There are two folders where an .str file exists: "strings_us" & "description"
#The LoadString() function only loads the items from the .str file found in the "strings_us" folder(or strings_de, etc...)
#These .str items must also be given their ID#s from the c4d_symbols.h file
#Since Python does not use the c4d_symbols.h file. It's usually empty...Don't get tripped up on this!!!!
#Most Python plugins declare the gizmo ID#s in an .h file located in the "description" folder
#Therefore, LoadString() will throw StrNotFound errors unless you also add them to the c4d_symbols.h file
#This code loads all of the .str resource items for all of the registered plugins in C4D(lots of them)
resource = c4d.plugins.GeResource()
resource.InitAsGlobal()
for i in xrange(0,400000) :
s = resource.LoadString(i)
if s != "StrNotFound": print s
#This code loads the .str items that are in the "strings_us" folder
#Reminder. If the ID#s are not being generated in the c4d_symbols.h file you'll get StrNotFound errors
dir, file = os.path.split(__file__) #Gets the plugin's directory
resource = c4d.plugins.GeResource()
resource.Init(dir)
for i in xrange(0,20) :
s = resource.LoadString(i)
if s != "StrNotFound": print s, " ", i
If you want to get the strings directly from the .str file that's in your "description" folder. The LoadString() function might not be a good option. But I'm no expert on this.
It might be better to use descriptions to get at them.
The support guys will probably offer better ideas when they get back next week.
-ScottA