• Insert my own command in main render Tab

    Cinema 4D SDK python 2023
    7
    0 Votes
    7 Posts
    2k Views
    P
    I really do appreciate all your effort and I will take your warning seriously and create my own menu Tab. Thanks again. Regards, Pim
  • Setting texture path to a RS Domelight with python

    Cinema 4D SDK r25 python
    2
    0 Votes
    2 Posts
    1k Views
    ferdinandF
    Hello @Ryan_Territory, Welcome to the Plugin Café forum and the Cinema 4D development community, it is great to have you with us! Getting Started Before creating your next postings, we would recommend making yourself accustomed with our Forum and Support Guidelines, as they line out details about the Maxon SDK Group support procedures. Of special importance are: Support Procedures: Scope of Support: Lines out the things we will do and what we will not do. Support Procedures: Confidential Data: Most questions should be accompanied by code but code cannot always be shared publicly. This section explains how to share code confidentially with Maxon. Forum Structure and Features: Lines out how the forum works. Structure of a Question: Lines out how to ask a good technical question. It is not mandatory to follow this exactly, but you should follow the idea of keeping things short and mentioning your primary question in a clear manner. About your First Question This exact question of yours has been asked before here for C++. Find a Python variant of the code below. For the technical details, I would recommend reading the older thread. Cheers, Ferdinand Result: [image: 1685984571549-557e9ddd-793a-4d07-aa6e-5ffd7ad05687-image.png] Code: import c4d # Define #Orslight, only must be done in pre 2023.0 API versions. c4d.Orslight: int = 1036751 def main(): doc = c4d.documents.GetActiveDocument() # Create Light light = c4d.BaseObject(c4d.Orslight) # Set the attributes light[c4d.REDSHIFT_LIGHT_TYPE] = c4d.REDSHIFT_LIGHT_TYPE_DOME # Define the texture parameter ID. texturePathId: c4d.DescID = c4d.DescID( # 1st DescLevel for the outer unexposed datatype of "Texture". c4d.DescLevel( c4d.REDSHIFT_LIGHT_DOME_TEX0, # The parameter ID (12000) for "Texture" 1036765, # The datatype ID for for "Texture", this type is not exposed, # we must use the raw ID. c4d.Orslight # The creator ID, Orslight in this case. ), # 2nd DescLevel for the inner exposed datatype of "Texture.Path". c4d.DescLevel( c4d.REDSHIFT_FILE_PATH, # The sub-channel parameter ID (1000) for "Texture.Path" c4d.DTYPE_STRING, # The data type ID of this component, string in this case. 0 # The creator ID, I just went with undefined here. )) light[texturePathId] = "asset:///file_c622e9ad3ea0e159" # Insert the light into the scene doc.InsertObject(light) c4d.EventAdd() if __name__=='__main__': main()
  • Move objects in the hierarchy

    Cinema 4D SDK python
    2
    1
    0 Votes
    2 Posts
    660 Views
    KantroninK
    I found the solution on https://plugincafe.maxon.net/ It was enough in the for loop to add the following line of code: for object in list_object: if object != object_root: object.InsertUnder(object_root) c4d.EventAdd()
  • 0 Votes
    3 Posts
    931 Views
    J
    Hello @jenandesign , without further questions or postings, we will consider this topic as solved by Friday, the 11th of august 2023 and flag it accordingly. Thank you for your understanding, Maxon SDK Group
  • Drive smooth rotation

    Cinema 4D SDK
    3
    0 Votes
    3 Posts
    626 Views
    J
    Hello @PMenich , without further questions or postings, we will consider this topic as solved by Friday, the 11th of august 2023 and flag it accordingly. Thank you for your understanding, Maxon SDK Group
  • Change alembic generator state/type

    Cinema 4D SDK python
    3
    0 Votes
    3 Posts
    831 Views
    J
    Hello @vik-lc , without further questions or postings, we will consider this topic as solved by Friday, the 11th of august 2023 and flag it accordingly. Thank you for your understanding, Maxon SDK Group
  • xRef file path is broken if created via python

    Cinema 4D SDK python 2023
    3
    0 Votes
    3 Posts
    689 Views
    B
    Sorry for not making my post as clear as it should have been, next time I will do better The good thing is, I fixed it! The problem was how I loaded my initial master project. # instead of using c4d.documents.LoadDocument() # i replaced it with c4d.documents.LoadFile() ... and now my xRef works just fine! Thank you again!
  • c4d.EventAdd() is not working

    Moved Bugs python 2023
    9
    0 Votes
    9 Posts
    2k Views
    ferdinandF
    Hey everyone, The issue has been fixed and verified in an internal build. It will be shipped with one of the builds of the next major update (i.e., it will not make it into 2023.x.y anymore). Beta testers can already make use of the change in the most recent beta build. Cheers, Ferdinand
  • How to get a port data type?

    Moved Bugs sdk python windows 2023
    6
    1
    0 Votes
    6 Posts
    1k Views
    J
    Hello @Dunhou , you are correct, the issue is not fixed yet. As Ferdinand mentioned in the beginning he has flagged it as "to_fix", so it will be fixed as soon as possible. Thanks and Cheers Maxon SDK Group
  • CRITICAL: Stop when calling SetWorldPluginData

    Cinema 4D SDK python 2023
    5
    0 Votes
    5 Posts
    1k Views
    a_blockA
    Thanks for the offer. much appreciated. But your explanations were good and plenty as usual. I think, I know exactly what is going on.
  • Setting DESC_DEFAULT for a Parameter has no Effect

    Cinema 4D SDK r23 python
    3
    0 Votes
    3 Posts
    782 Views
    J
    Hello @mikeudin , without further questions or postings, we will consider this topic as solved by Friday, the 11th of august 2023 and flag it accordingly. Thank you for your understanding, Maxon SDK Group
  • 0 Votes
    7 Posts
    1k Views
    B
    @ferdinand Gotcha. Thanks. Will close this thread now.
  • Undo for commanddata plugin principle

    Cinema 4D SDK python
    6
    0 Votes
    6 Posts
    1k Views
    J
    Hello @datamilch , without further questions or postings, we will consider this topic as solved by Friday, the 11th of august 2023 and flag it accordingly. Thank you for your understanding, Maxon SDK Group
  • 0 Votes
    11 Posts
    2k Views
    DunhouD
    Hi @m_adam , I have ask what are main functions in redshift do in redshift forum, but get no reply for week. and the help(redshift) also give me an ambiguous result. But anyway, I have something here, I will update it and publish when I have free times.
  • 0 Votes
    4 Posts
    1k Views
    T
    Hi @ferdinand, your links really helped me a lot, and I managed to write a script that starts a render and sends the rendered image to a web service. Can the SDK grab the live preview image from the redshift IPR? I assume not looking at the documentation: https://developers.maxon.net/docs/py/2023_2/search.html?q=redshift&check_keywords=yes&area=default
  • ObjectData plugin. How to store class object data?

    Cinema 4D SDK python r23
    4
    0 Votes
    4 Posts
    1k Views
    ferdinandF
    Hey @mikeudin, that the problem appears when calling "Reset To Default" command (from context menu or by right-click on arrows) What does constitute as 'the problem' here for you? But: You should initialize the data parameter with .InitAttr. I forgot to do that in my code example myself and now have added it. But that should not be the cause of your problem, whatever it is. As shown above and in the other thread, Cinema reinitializes nodes that users would consider "the same". A hook is reinitialized for the same node when that node has been reallocated. When some data is not recomputable, or too expensive to, you must the check in Init if the data does already exist. # The actual tag in the scene is allocated and initialized. Init: mem: 0X7F95D530E3C0, uuid: b'\x14}\xda\xa4\xdb\xf2\x17\x01\x19\xc1\xf7\x00\x079\x00\x00' # An Asset API temp tag is being initialized and then freed right away. Init: mem: 0X7F95D5318500, uuid: b'\x14}\xda\xa4\xdb\xf2\x17\x01$\xc1\xf7\x00Q9\x00\x00' Free: mem: 0X7F95D5316640, uuid: b'\x14}\xda\xa4\xdb\xf2\x17\x01$\xc1\xf7\x00Q9\x00\x00' # The actual tag in the scene is reinitialized. Init: mem: 0X7F95D5314FC0, uuid: b'\x14}\xda\xa4\xdb\xf2\x17\x01\x19\xc1\xf7\x00\x079\x00\x00' # An Asset API temp tag is being initialized and then freed right away. Init: mem: 0X7F95D52E9E40, uuid: b'\x14}\xda\xa4\xdb\xf2\x17\x01p\xc9\xf7\x00\xc49\x00\x00' Free: mem: 0X7F95D52E30C0, uuid: b'\x14}\xda\xa4\xdb\xf2\x17\x01p\xc9\xf7\x00\xc49\x00\x00' # The actual tag in the scene is reinitialized. Init: mem: 0X7F95D52FB3C0, uuid: b'\x14}\xda\xa4\xdb\xf2\x17\x01\x19\xc1\xf7\x00\x079\x00\x00' # An Asset API temp tag is being initialized and then freed right away. Init: mem: 0X7F95D53096C0, uuid: b'\x14}\xda\xa4\xdb\xf2\x17\x01\xdd\xcd\xf7\x006:\x00\x00' Free: mem: 0X7F95D530A180, uuid: b'\x14}\xda\xa4\xdb\xf2\x17\x01\xdd\xcd\xf7\x006:\x00\x00' # The actual tag in the scene is reinitialized. Init: mem: 0X7F95D5309F00, uuid: b'\x14}\xda\xa4\xdb\xf2\x17\x01\x19\xc1\xf7\x00\x079\x00\x00' # An Asset API temp tag is being initialized and then freed right away. Init: mem: 0X7F95D52F9D00, uuid: b'\x14}\xda\xa4\xdb\xf2\x17\x01\x9c\xd9\xf7\x00\xaf:\x00\x00' Free: mem: 0X7F95D52FD980, uuid: b'\x14}\xda\xa4\xdb\xf2\x17\x01\x9c\xd9\xf7\x00\xaf:\x00\x00' # The actual tag in the scene is reinitialized. Init: mem: 0X7F95D52FD940, uuid: b'\x14}\xda\xa4\xdb\xf2\x17\x01\x19\xc1\xf7\x00\x079\x00\x00' # An Asset API temp tag is being initialized and then freed right away. Init: mem: 0X7F95D5317A80, uuid: b'\x14}\xda\xa4\xdb\xf2\x17\x01,\xdd\xf7\x00Q;\x00\x00' Free: mem: 0X7F95D5313EC0, uuid: b'\x14}\xda\xa4\xdb\xf2\x17\x01,\xdd\xf7\x00Q;\x00\x00' Other than that, I cannot say much, without understanding what is exactly going wrong. We will also need executable code, so that we can debug things ourselves as this is not a trivial topic. Cheers, Ferdinand
  • Getting only the last value of the slider (slide)

    Moved Bugs 2023 python
    5
    1
    0 Votes
    5 Posts
    1k Views
    P
    Great work!!! Thank you. Regards, Pim
  • 0 Votes
    3 Posts
    728 Views
    T
    would love to see that being added. the HUD is amazing for internal tooling
  • 0 Votes
    3 Posts
    653 Views
    i_mazlovI
    Hi @pim, Thanks for reaching out to us. The links are document-specific so they only make any sense in the context of the document that they were created in. It means that once stored, restoring them back would only correspond to the exact same objects in the exact same document. If it's not your case, then you'd need to define the criteria of what you mean by two objects being the same (is it only a name or a combination of the name with any other properties, e.g. hierarchy?). However, if the context of these objects stays the same, then you can use the same trick as @ferdinand mentioned in the point selection thread. Namely, using MAXON_CREATOR_ID for extracting the UUIDs of the objects. These UUIDs can be stored in the Hyperfile (just as simple strings). So whenever you need to restore them, you would need to traverse the document tree and compare the actual object UUID with the one you're restoring. One can also use GetClassification() function to retrieve the type of the object, which would make traversing the document a little more efficient. Please find the sample script implementing the explained approach below. Let me know if you have any further questions. Cheers, Ilia [image: 1684233709032-cinema_4d_ifzokeu8lw.gif] import c4d LINK_OBJ_ID = 1001 LINK_MAT_ID = 1002 BTN_SAVE_ID = 1003 BTN_LOAD_ID = 1004 BTN_RESET_ID = 1005 HF_IDENT = 49545 PATH = 'd:\\_tmp\\lnkbox.bin' class MainDialog(c4d.gui.GeDialog): def __init__(self): self.linkBoxes : dict[int, c4d.gui.BaseCustomGui] = {} def CreateLayout(self): self.GroupBegin(2001, c4d.BFH_FIT, cols=1) self.linkBoxes[0] = self.AddCustomGui(LINK_OBJ_ID, c4d.CUSTOMGUI_LINKBOX, "Obj", c4d.BFH_SCALEFIT, 100, 4) self.linkBoxes[1] = self.AddCustomGui(LINK_MAT_ID, c4d.CUSTOMGUI_LINKBOX, "Mat", c4d.BFH_SCALEFIT, 100, 4) self.GroupEnd() self.GroupBegin(2002, c4d.BFH_FIT, cols=3) self._btnSave = self.AddButton(BTN_SAVE_ID, c4d.BFH_SCALEFIT, name="Store links") self._btnLoad = self.AddButton(BTN_RESET_ID, c4d.BFH_SCALEFIT, name="Reset links") self._btnSave = self.AddButton(BTN_LOAD_ID, c4d.BFH_SCALEFIT, name="Load links") self.GroupEnd() return True def Command(self, id, msg): if id == BTN_SAVE_ID: self.save(PATH) elif id == BTN_LOAD_ID: self.load(PATH) elif id == BTN_RESET_ID: self.reset() return True @staticmethod def GetUUID(node: c4d.C4DAtom) -> bytes: """Returns an UUID for #node which identifies it over reallocation boundaries""" if not isinstance(node, c4d.C4DAtom): raise TypeError(f"{node = }") data: memoryview = node.FindUniqueID(c4d.MAXON_CREATOR_ID) if not isinstance(data, memoryview): raise RuntimeError(f"Could not access UUID for: {node}") return bytes(data) @staticmethod def traverseSubtree(bl : c4d.BaseList2D): """Half-recursively iterates over baselist elements and its children""" while bl: yield bl for child in MainDialog.traverseSubtree(bl.GetDown()): yield child bl = bl.GetNext() @staticmethod def traverseDocument(doc : c4d.documents.BaseDocument, callBack, classification): """Executes callback for each document element depending on classification""" if doc is None: raise ValueError("doc is None") bl : c4d.BaseList2D = None if classification == c4d.Obase: bl = doc.GetFirstObject() elif classification == c4d.Mbase: bl = doc.GetFirstMaterial() for op in MainDialog.traverseSubtree(bl): if not callBack(op): # callback returns false if no further traversing needed return def reset(self): """Reset links in the gui""" for lnkbox in self.linkBoxes.values(): lnkbox.SetLink(None) def save(self, path): """Store links UUID and Classification in the Hyperfile""" bcFile = c4d.BaseContainer() hf = c4d.storage.HyperFile() if hf.Open(ident=HF_IDENT, filename=path, mode=c4d.FILEOPEN_WRITE, error_dialog=c4d.FILEDIALOG_NONE): for idx, lnkbox in self.linkBoxes.items(): lnk : c4d.BaseList2D = lnkbox.GetLink(c4d.documents.GetActiveDocument()) if lnk is None: print("No link selected!") continue uuid : str = MainDialog.GetUUID(lnk).hex() bc = c4d.BaseContainer() bc[0], bc[1] = uuid, lnk.GetClassification() bcFile.SetContainer(idx, bc) hf.WriteContainer(bcFile) else: c4d.gui.MessageDialog("Couldn't open file for writing") hf.Close() def load(self, path): """Unpack UUIDS from Hyperfile and search for corresponding objects""" uuid : str = None obj : c4d.BaseObject = None classification : int = 0 def process(op): """Callback lambda: store object once the correct one has been found""" nonlocal obj if op is not None and MainDialog.GetUUID(op).hex() == uuid: obj = op return False return True hf = c4d.storage.HyperFile() if hf.Open(ident=HF_IDENT, filename=path, mode=c4d.FILEOPEN_READ, error_dialog=c4d.FILEDIALOG_NONE): bcFile : c4d.BaseContainer = hf.ReadContainer() for idx, lnkbox in self.linkBoxes.items(): bc : c4d.BaseContainer = bcFile.GetContainer(idx) uuid, classification = bc[0], bc[1] MainDialog.traverseDocument(c4d.documents.GetActiveDocument(), process, classification) if uuid is not None and obj is not None: lnkbox.SetLink(obj) else: c4d.gui.MessageDialog("Couldn't open file for reading") hf.Close() if __name__=='__main__': dlg = MainDialog() dlg.Open(c4d.DLG_TYPE_ASYNC, defaultw=256, xpos=-2, ypos=-2)
  • ExecutePasses to slow

    Cinema 4D SDK python
    8
    0 Votes
    8 Posts
    1k Views
    J
    Hello @Joel, without further questions or postings, we will consider this topic as solved by Friday, the 11th of august 2023 and flag it accordingly. Thank you for your understanding, Maxon SDK Group