• Texture renaming

    Moved Cinema 4D SDK python
    16
    0 Votes
    16 Posts
    2k Views
    M
    @zipit hm yes this sounds too complicated overall, particularly point 3 there could so much happen on the os side. A gui with more options like renaming the hole texturename or a replace option of certain words could be the way forward. Instead of undo it would be easy then to rename the texture with he old name etc. for now im happy how this works and let this solved. Much Thanks! Cheers, moko
  • Modifying timeline marker's attributes

    Cinema 4D SDK
    5
    0 Votes
    5 Posts
    1k Views
    H
    Thanks for the drag'n'drop tip Maxime, that feature is extremely useful!
  • 0 Votes
    4 Posts
    474 Views
    M
    Hi Pim sorry for the late reply, this is possible by using the lib_py.h (typically this is somehow what we used before R20 to expose feature in python, but it's way elder, not everything is possible to do, you have less control than with the new python.framework, and the lib_py.h is not maintained (so don't expect any enhancement in it) Only the python.framework will be enhanced. // Init Python GePython pythonScope; pythonScope.Init(); // Acquiere the GIL GePythonGIL gil_state; pythonScope.SetNode("doc", doc); // If doc->GetFirstObject() is nullptr, op variable will not be declared in the python scope, and you cant add a None. pythonScope.SetNode("op", doc->GetFirstObject()); maxon::String pythonCode = "\ import c4d\n\ \n\ def main():\n\ print(doc, op)\n\ \n\ if __name__ == '__main__' :\n\ main()\n\ "_s; StopAllThreads(); pythonScope.Run(pythonCode); Cheers, Maxime.
  • Passing a variable to the python script

    Cinema 4D SDK r20 c++ python
    5
    0 Votes
    5 Posts
    727 Views
    ferdinandF
    Hi, yeah like that. __name__ is just another module bound constant attribute. It is a dunder attribute, signaling a special importance, indicated by its double underscores, but that is only a convention and not a functionality. You can set __name__ to anything you like, just like you could set __author__ to your favourite ice cream brand. The convention dictates that __name__ tells the script in which context is being executed, where __main__ should signal that the module is executed directly. You could set it to my_cpp for example, so that your scripts could react differently to being executed from your C++ code. Cheers, zipit
  • 0 Votes
    3 Posts
    665 Views
    G
    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
  • Create a download progress bar in python

    Cinema 4D SDK python
    5
    0 Votes
    5 Posts
    1k Views
    M
    @indexofrefraction and just in case you have this example from CUSTOMGUI_PROGRESSBAR if you want a more minimal script. Cheers, Maxime.
  • 0 Votes
    4 Posts
    1k Views
    ManuelM
    Hi, I often use the python generator to create some prototype myself. So it's ok for me. But if you want to give or sell your result, you should move to a plugin. It's not hard at all, if you already did that prototype, the plugin is easy, and we are here in case you have some issue. Nice result Cheers, Manuel
  • Insert String Info Into AddStaticText dialog command

    Moved Cinema 4D SDK
    3
    0 Votes
    3 Posts
    549 Views
    G
    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
  • Can't work out BaseDocument.StartPickSession

    Cinema 4D SDK python r21
    7
    0 Votes
    7 Posts
    1k Views
    M
    Without a further reply from you until tomorrow I will consider and mark this topic as solved, but feel free to open it again if you have more information. Cheers, Maxime.
  • Extending the Command Line with Python

    Cinema 4D SDK python r21
    10
    0 Votes
    10 Posts
    3k Views
    moghurtM
    @jwzegelaar said in Extending the Command Line with Python: We found a good workaround! We now made a custom commandline plugin where we can add our own arguments. And it works great. If anybody in the future has this issue you can always contact us and we will help. Thanks again everybody for all the help! Hi jwzegelaar, I believe that I share the same needs as you, where I also need to pass in external parameters via a .py file to make modifications to the file before rendering. Unfortunately, I am encountering the same issue as you. Although this post has been quite some time, I am still hopeful for your assistance. Your help would be greatly appreciated and it is highly important to me.
  • 1 Votes
    4 Posts
    1k Views
    C
    Did GetClonePart and it works Cinema4D Preview Icon [image: 1584841017304-unknown.png] [image: 1584841026677-demoicons.png] [CODE HERE] # // Imports // import os import sys # // Imports for Cinema 4D // import c4d from c4d import plugins, gui, bitmaps, documents, storage, utils # Icons Image Paths OneImageIcons = os.path.join(os.path.dirname(__file__), 'icons', "demoIcons.png") # --------------------------------------------------------------------- # Creating GUI Instance Functions UI Elements Operations # Hepler Methods. # --------------------------------------------------------------------- # Get Icon from Icons one image. def GetCustomIcon(size, locCordX, locCordY): """ Get Texture Atlas Image """ bmp = c4d.bitmaps.BaseBitmap() bmp.InitWith(OneImageIcons) w = size h = size x = locCordX y = locCordY selectIcon = bmp.GetClonePart(x, y, w, h) return selectIcon # Create a Bitmap Button Custom GUI. def CustomImageButton_GUI(ui_ins, btn_id, toolname, tooltip, image): ui_ins.GroupBegin(0, c4d.BFH_MASK, 1, 0, "") bc = c4d.BaseContainer() # Create a new container to store the button image bc.SetLong(c4d.BITMAPBUTTON_BORDER, c4d.BORDER_NONE) # Sets the border flag to look like a button look. eg.( c4d.BORDER_NONE or c4d.BORDER_THIN_OUT or c4d.BORDER_OUT ) bc.SetBool(c4d.BITMAPBUTTON_BUTTON, True) # Clickable button / Does not seem to to work in R13? bc.SetBool(c4d.BITMAPBUTTON_TOGGLE, True) # Toggle button, like a checkbox. bc.SetString(c4d.BITMAPBUTTON_TOOLTIP, "<b>"+ toolname + "</b><br>" + tooltip) ui_ins.myBitButton = ui_ins.AddCustomGui(btn_id, c4d.CUSTOMGUI_BITMAPBUTTON, "Bitmap Button", c4d.BFH_MASK, 10, 10, bc) ui_ins.myBitButton.SetImage(image) ui_ins.GroupEnd() return True # ---------------------------------------- # // UI Main Window // # ---------------------------------------- class Tool_WindowDialog(c4d.gui.GeDialog): # GUI Ids IDS_VER = 999 IDS_OverallGrp = 1000 IDS_StaticText = 1001 IDS_BTN_01 = 1002 IDS_BTN_02 = 1003 IDS_BTN_03 = 1004 IDS_BTN_04 = 1005 # // Main GeDialog Overrides // """ The __init__ is an Constuctor and help get and passes data on from the another class. """ def __init__(self): super(Tool_WindowDialog, self).__init__() # UI Layout def CreateLayout(self): # Dialog Title self.SetTitle("Tool Ui") # Adding the GUI Buttons and inside a empty group with 4 rows. self.GroupBegin(0, c4d.BFH_SCALEFIT, 4, 0, "") self.GroupBorderSpace(5, 5, 5, 5) CustomImageButton_GUI(ui_ins=self, btn_id=self.IDS_BTN_01, toolname="Go UP", tooltip="HelloWorld", image=GetCustomIcon(size=32, locCordX=0, locCordY=37)) CustomImageButton_GUI(ui_ins=self, btn_id=self.IDS_BTN_02, toolname="Go Right", tooltip="HelloWorld", image=GetCustomIcon(size=32, locCordX=0, locCordY=0)) self.GroupEnd() self.GroupEnd() # End of the overall group. return True # Called when the dialog is initialized by the GUI / GUI's with startup values basically. def InitValues(self): print("Yang Ultimate Tools Dialog is open.") return True # Adding Excuting Commands Functions for UI Elements. def Command(self, id, msg): if id == id: print(str(id)) return True # Override this function if you want to react to Cinema 4D core messages. # The original message is stored in msg def CoreMessage(self, id, msg): if id == c4d.EVMSG_CHANGE: #self.add_images() pass return True """ DestroyWindow Override this method - this function is called when the dialog is about to be closed temporarily, for example for layout switching. """ def DestroyWindow(self): print("Tools Dialog Close.") if __name__=='__main__': class_dialog = Tool_WindowDialog() class_dialog.Open(c4d.DLG_TYPE_ASYNC, defaultw=200, defaulth=10)
  • Apply a step value in SetHandle function

    Cinema 4D SDK python
    4
    0 Votes
    4 Posts
    565 Views
    mfersaouiM
    @zipit Hi, Thank you.
  • 0 Votes
    3 Posts
    831 Views
    M
    Hi sorry I overlook your answers, There is no way to directly change the path in the RenderQueue to do so, you have to edit the document. So before adding a document, you need to load them, then define the path in the render setting and then resave the file. Here a quick example. import c4d # Load the document docPath = r"PATHtoc4dFile.c4d" doc = c4d.documents.LoadDocument(docPath, c4d.SCENEFILTER_OBJECTS | c4d.SCENEFILTER_MATERIALS, None) # Retrieves the active render setting renderData = doc.GetActiveRenderData() # Set the new path for the picture renderData[c4d.RDATA_PATH] = r"MyPicturePath.exr" # Save the document c4d.documents.SaveDocument(doc, docPath, c4d.SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST, c4d.FORMAT_C4DEXPORT) Cheers, Maxime.
  • How to Solo a Layer

    Cinema 4D SDK
    3
    0 Votes
    3 Posts
    773 Views
    r_giganteR
    Hi @dskeith thanks for reaching out us. As pointed out by @PluginStudent, the NBIT_SOLO_LAYER behavior is explained in the Layer Manuel although it make sense to add a note to the Python API as well. With regard to a complete example, I've partially reworked your code to make sure that by executing the script multiple times you can run across all the solo configurations that the scene can handle. import c4d # Main function def main(): layer_root = doc.GetLayerObjectRoot() if not layer_root: return # Get the first layer in the scene layer = layer_root.GetDown() if not layer: return soloSet = False while layer is not None: # Set `rawdata` to True flag so to get the original layer values without any additional global changes layer_data = layer.GetLayerData(doc, rawdata=True) # check the current layer solo state: if layer_data["solo"] == False: # if not "solo" then set to True layer_data["solo"] = True # update the layer layer.SetLayerData(doc, layer_data) # update the flag soloSet = True break # deactivate if layer solo was True layer_data["solo"] = False layer.SetLayerData(doc, layer_data) # go to next layer layer = layer.GetNext() # if one (or more) solo was set the set NBIT_SOLO_LAYER otherwise clear if soloSet == True: doc.ChangeNBit(c4d.NBIT_SOLO_LAYER, c4d.NBITCONTROL_SET) else: doc.ChangeNBit(c4d.NBIT_SOLO_LAYER, c4d.NBITCONTROL_CLEAR) # Add an event c4d.EventAdd() # Execute main() if __name__=='__main__': main() Cheers
  • Matrix.__mul__(self, other) documentation ambiguity

    Cinema 4D SDK python
    2
    0 Votes
    2 Posts
    257 Views
    r_giganteR
    Thanks a lot @zipit . I indeed agree and will update the documentation accordingly. Best and stay safe! R
  • How can i render/add render queue in Python ?

    Moved Cinema 4D SDK
    4
    0 Votes
    4 Posts
    902 Views
    ManuelM
    hi, I've moved the answer about the output path to this thread Cheers, Manuel
  • c4d.ObjectData plugin code execution sequence

    Cinema 4D SDK python
    8
    0 Votes
    8 Posts
    1k Views
    ManuelM
    hi, without further feedback i'll set this thread as solved tomorrow. Cheer, Manuel
  • 0 Votes
    5 Posts
    688 Views
    ?
    @m_magalhaes Thank you for this workaround. I hope to see that bug fixed soon! It seems like one that would affect many scripts & plugins.
  • Avoid: IsActive()

    Cinema 4D SDK python classic api
    10
    0 Votes
    10 Posts
    1k Views
    lasselauchL
    Thanks @m_adam for the insights! Works like a charm!! Cheers, Lasse
  • "History" xpresso node python analogue?

    Moved Cinema 4D SDK
    12
    0 Votes
    12 Posts
    2k Views
    ManuelM
    hi, can we considered this thread as solved ? (at least we answered your question) Without further feedback i'll set it to solved tomorrow. Cheers, Manuel