this is not possible. ObjectData is a class of the "classic" API. The Maxon API has no equivalent counterpart.
You get an overview over plugin types here: Plugin Types.
at the end of this week, I will leave Maxon for a new direction in my life.
In the last five years, I tried to give you the best answers to your questions and to provide you with documentation and examples that would make your daily life easier.
During my time here, I met remarkable developers and learned about their projects. I learned a lot by working with you here on the forum, via mail or in person. Especially, I want to thank Riccardo, Maxime and Manuel for being great colleagues and an amazing team. Be assured that this team will continue to work with great commitment to make sure you get the support you need.
I wish you all the best.
please use tags and the Q&A system when posting questions.
What version of Cinema 4D and the SDK are you using?
You can enable utility functions like
NewObjClear() by enabling this setting in your
and re-creating the project files. See Project Tool.
there is no "official" way of handling or reporting errors in Python scripts. You can do whatever fits your needs or the needs of your user best. Why do you think the console is not useful to users?
The only thing to consider are general best practices regarding software design. E.g. to only show a (modal) dialog when you know that a user is interacting with the software, not in some sub-function.
Another philosophical discussion is, what actually is an error? An error should be returned by a function that failed; but what does that mean? What should happen if an error is detected? (Here is some video about this topic I just recently watched: https://www.youtube.com/watch?v=GC4cp4U2f2E)
For argument's sake, lets say an error is when something in your code, you are 100% sure should and must work, didn't work. So your program shuts down, if such such an "error" was detected.
In your example, LoadDialog() is a function that - in my opinion - cannot fail. Either the user selects a folder or he presses "Cancel". Both are fine results. And if the user tells you to abort, you can simply exit your program.
Similarly, when the user selects the wrong file type, that's not a program error. Compare that with a user entering a wrong password somewhere - that is not an error, but something to expect. Providing feedback to the user and handling errors are two different things.
def handleError(error): print(error) c4d.gui.MessageDialog(error) def getImagePathFromUserInteraction(): res = c4d.storage.LoadDialog( type=c4d.FILESELECTTYPE_IMAGES, title="Select an image in the folder you want to bulk rename", flags=c4d.FILESELECT_LOAD ) if res == None: return False return res def main(): # UI interaction res = getImagePathFromUserInteraction() if res == False: # nothing to do, lets go home print("script aborted by user") return # do actual work try: doSomething(res) doSomethingElse(res) except ValueError as error: handleError(error) return # show result in the UI c4d.gui.MessageDialog(res)
@bentraje You find also some information in this discussion: Miscellaneous questions about "BaseContainer","DescID" etc
I don't know why you think you need two groups.
You can simply have one group that you flush and re-fill on demand. In that re-fill, you can replace anything with that static text placeholder as shown above:
self.LayoutFlushGroup(1000) flags = c4d.BFH_LEFT | c4d.BFV_TOP width = c4d.gui.SizePix(100) height = c4d.gui.SizePix(100) if self.mode == True: # add bitmap button settings = c4d.BaseContainer() settings.SetBool(c4d.BITMAPBUTTON_BUTTON, False) bitmapButtonGUI = self.AddCustomGui(1001, c4d.CUSTOMGUI_BITMAPBUTTON, "", flags, width, height, settings) if bitmapButtonGUI is not None: icon = c4d.gui.GetIcon(c4d.Ocube) bmp = icon["bmp"] subBitmap = c4d.bitmaps.BaseBitmap() bmp.CopyPartTo(subBitmap, icon["x"], icon["y"], icon["w"], icon["h"] ) bitmapButtonGUI.SetImage(subBitmap, True, False) else: # add placeholder with the size of the bitmap button self.AddStaticText(999, flags, width, height) self.LayoutChanged(1000)
what exactly do you mean with "button"?
A standard button (
AddButton()), a bitmap button or a custom
GeUserArea based gadget?
@lasselauch 's idea to use
Enable() is, I guess, the easiest way to achieve what you want. But what is the overall behaviour of your dialog? Is the user able to resize it; can the width or height or your GUI elements changes based on resizing the dialog? Do your UI elements have a minimum or fixed size?
If the element has fixed size, you can insert an empty static text element with the desired dimensions in place of the original element when rebuilding your layout.
self.AddStaticText(999,c4d.BFH_LEFT | c4d.BFV_TOP, c4d.gui.SizePix(100), c4d.gui.SizePix(100))
as always, efficiency is the result of good software design. One way of speeding things up is to use caches.
DrawMsg() is called by Cinema whenever Cinema things something might have changed. I don't think you can do anything about that.
You have to make sure that within DrawMsg() you only draw and do nothing else. Why are you loading the bitmap in the context of DrawMsg()? Why are you scaling the images in the context of DrawMsg()? Why not earlier?
I guess at some point, your program knowns what images to display. At that point you could load all these (scaled) images into a cache. Then in DrawMsg(), you can simply access the data in that cache.
Depending on the reason for the redraw, you could optimize further. E.g. you could use a GeClipMap to draw whatever you want into a BaseBitmap and simply draw that BaseBitmap in the context of DrawMsg().
Speed is the result of software design. Caches can help, but of course they increase code complexity and memory footprint.