• Nesting Pivot object causes parent to shoot up into space

    Cinema 4D SDK
    6
    0 Votes
    6 Posts
    872 Views
    ferdinandF
    Hey @HerrMay, Great to hear that you solved your problem. Cheers, Ferdinand
  • Automatic UV Rectangularize / MDATA_UVRECTANGULARIZE

    Cinema 4D SDK
    2
    0 Votes
    2 Posts
    590 Views
    M
    Hi sadly the only way is to use c4d.CallCommand(1055347) which does not open the window but directly execute the command. You can change the setting as you could in the windows, by editing the value in the BaseContainer of the document. Finally it act on the selected polygon, so the best way would be to select them. Find bellow a script that you can execute in the script manager that will select all polygon of an object and run the command. from typing import Optional import c4d doc: c4d.documents.BaseDocument # The active document op: Optional[c4d.BaseObject] # The active object, None if unselected def main() -> None: # Enables UV Polygon Mode if not already in any UV mode (needed for GetActiveUVSet to works) if doc.GetMode() not in [c4d.Muvpoints, c4d.Muvpolygons]: doc.SetMode(c4d.Muvpolygons) # Retrieves active UVSet, The UV windows need to be opened at least one time handle = c4d.modules.bodypaint.GetActiveUVSet(doc, c4d.GETACTIVEUVSET_ALL) if handle is None: # If fail it may be because the Texture view is not open # Open A texture View c4d.CallCommand(170103) # In S22 you need to update the UV Mesh if c4d.API_VERSION >= 22000: c4d.modules.bodypaint.UpdateMeshUV(False) # Retrieves active UVSet, The UV windows need to be opened at least one time handle = c4d.modules.bodypaint.GetActiveUVSet(doc, c4d.GETACTIVEUVSET_ALL) if handle is None: raise RuntimeError("There is no Active UVSet") # Select the polygon you want to operate on currentSel = op.GetPolygonS() previousSel = currentSel.GetClone() # Will be used to restore the initial selection state at the end currentSel.SelectAll(op.GetPolygonCount() - 1 ) # Update the UV mesh to properly take into account the new selection c4d.modules.bodypaint.UpdateMeshUV(True) # Define the settings settings = doc.GetSettingsInstance(c4d.DOCUMENTSETTINGS_MODELING) settings[c4d.MDATA_UVRECTANGULARIZE_ALIGN] = True settings[c4d.MDATA_UVRECTANGULARIZE_EQUIDISTANT] = False # Execute the command c4d.CallCommand(1055347) # Restore the initial selection previousSel.CopyTo(currentSel) c4d.modules.bodypaint.UpdateMeshUV(True) c4d.EventAdd() if __name__ == '__main__': main() Cheers, Maxime.
  • 0 Votes
    3 Posts
    487 Views
    V
    @ferdinand Thank you for the hint and the superfast response! I was not aware that these symbols dissolve into these numbers, which of course makes it much easier to work with them now. I was able to solve it with CallUVCommand: settings = c4d.BaseContainer() settings[c4d.RELAXUV_KEEP_BORDER] = False settings[c4d.RELAXUV_KEEP_NEIGHBORS] = False settings[c4d.RELAXUV_KEEP_POINTSEL] = False settings[c4d.RELAXUV_CUT_EDGESEL] = True settings[c4d.RELAXUV_EDGESEL_POINTER] = edge_sellection settings[c4d.RELAXUV_MAX_ITERATIONS] = 1 settings[c4d.RELAXUV_MODE] = c4d.RELAXUV_MODE_ABF ret = c4d.modules.bodypaint.CallUVCommand(handle.GetPoints(), handle.GetPointCount(), handle.GetPolys(), handle.GetPolyCount(), uvw, handle.GetPolySel(), handle.GetUVPointSel(), obj, handle.GetMode(), c4d.UVCOMMAND_RELAX, settings)
  • Need help fixing export to GLTF script

    General Talk
    3
    0 Votes
    3 Posts
    939 Views
    i_mazlovI
    Hello @joel_motion, 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 Support for redshift materials on gltf export first appeared with the 2023.2 release. That version also included numerous gltf exporter stability improvements. Please note, that debugging the code is out of scope in this forum. You are very welcome to ask specific questions with well-defined scope. In general your code seems reasonable. The approach with cloning objects onto a new document is the one I would suggest anyways. However, one should be careful with the dependencies that objects in the subtree might loose during cloning. AliasTrans helps to overcome such side effects to some extent. Cheers, Ilia
  • GvOperatorData, GetDDescription() problems

    Cinema 4D SDK sdk s26
    6
    0 Votes
    6 Posts
    1k Views
    J
    Hello @Filip , 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
    10 Posts
    2k Views
    F
    Great, thanks a lot for looking into this and for the detailed explanations! Now I know better what my options are! I am marking this thread as "solved". Best regards Filip Malmberg
  • CommandData Plugin DrawHUD

    Cinema 4D SDK s26 python
    3
    0 Votes
    3 Posts
    494 Views
    J
    Hello @gheyret , 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
  • How to add custom menu to take manager

    Cinema 4D SDK
    3
    0 Votes
    3 Posts
    607 Views
    H
    Hi @i_mazlov, thank you for your reply. Yes, I thought as much. Too bad the take manager menu is not publicy exposed. And while I understand that Maxon as well as the community are not big fans of every plugin messing around with menu insertions, it still is a pitty. One can e.g. insert plugins into the menu of the material manager as done so by "CV-Swim". IMHO it should pose no problem when done carefully with UX in mind while doing so. Especially when one "only" appends entries to a menu. Nethertheless thank you for confirmation. Cheers, Sebastian
  • Viewport render always causing c4d stop running

    General Talk s22 s26
    6
    0 Votes
    6 Posts
    2k Views
    chuanzhenC
    The problem has been resolved, reinstall the graphics driver and perform a custom clean installation!
  • How to create ToolBox in C++.

    Cinema 4D SDK s26 c++ windows
    3
    2
    0 Votes
    3 Posts
    722 Views
    P
    @ferdinand Thank you
  • TreeView DropDown Menu

    Cinema 4D SDK
    3
    0 Votes
    3 Posts
    892 Views
    ferdinandF
    Hello @simonator420, Thank you for reaching out to us. As announced here, Maxon is currently conducting a company meeting. Please understand that our capability to answer questions is therefore limited at the moment. I am slightly confused about the nature of your questions, especially in the context of the reply from @mogh. TreeViewFunctions.GetDropDownMenu lets you define the content of drop down menus in a TreeView, and the slightly ill named SetDropDownMenu lets you react to an item being selected in such menu. The 'problem' with your code snippet is that you do not differentiate the drop down gadgets which are set in GetDropDownMenu. Like many methods of TreeViewFunctions it is called for each cell in the tree view table, where lColumn denotes the column as defined in your TreeViewCustomGui.SetLayout call, and obj denotes an item in your root, so sort of the row in the tree. lColumn becomes meaningless when your tree view has only one column of type LV_DROPDOWN. How to make sense of obj, depends on the shape of the data you passed as root. When root root is just a list[object], you could for example alternate between even and odd rows like this. def GetDropDownMenu( self, root: list[object], userdata: any, obj: object, lColumn: int, menuInfo: dict): """Simple example for defining the menu content based on the position of #obj in #root. """ index: int = root.index(obj) if index % 2 == 0: menuInfo["menu"][1000] = "Even row first option" menuInfo["menu"][1001] = "Even row second option" else: menuInfo["menu"][1000] = "Odd row first option" menuInfo["menu"][1001] = "Odd row second option" menuInfo["state"] = int(menuInfo["state"]) In practice, the content of a drop down is more likely to be determined based on the fields of obj (e.g., if obj.a == "foo" then Menu1 else Menu2)rather than its relative position in root (be it a list-like or tree-like data structure). Cheers, Ferdinand
  • 0 Votes
    3 Posts
    599 Views
    i_mazlovI
    Hello @DjNikMax, 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 follow the idea of keeping things short and mentioning your primary question in a clear manner. About your First Question The goal you're trying to achieve is a unclear and the proposed steps look redundant. There're a couple of topics I'd like to mention regarding your provided code: Using doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_CHILDREN) doesn't make any sense in this context, because children are removed when calling "Connect Objects + Delete" command Using c4d.CallCommand(16768) applies this command to the currently selected objects (rather than to the obj on the current loop iteration) If you process objects one-by-one there's no need to group it beforehand, the "Connect Objects + Delete" command can be run directly on the object itself. This would bake rotation and scale into the mesh itself, the position would remain exactly the same as in the original object (without any extra step, no need to instantiate the object and copy it's coordinates back to the baked mesh) If you want to zero-out object position after baking it, you might want to look into freeze transform functionality: c4d.ID_BASEOBJECT_FREEZE_P If you anyways want to deal with transformations, you can check the thread about matrices, mentioned in above. @mogh, thank you for sharing! Let me know if you still have any questions. Cheers, Ilia
  • Defer Modifying Menus to the Main Thread

    Cinema 4D SDK python s26
    6
    0 Votes
    6 Posts
    2k Views
    alexandre.djA
    @ferdinand Just a quick update that using an event message to force update the view after creating the menus is working great. c4d.EventAdd(c4d.EVMSG_CHANGE)
  • How to obtain all vertices of an object in C++.

    Cinema 4D SDK s26 c++ sdk
    3
    0 Votes
    3 Posts
    585 Views
    P
    @m_adam Thanks
  • Cinema 4D Unable to use MATLAB library

    Cinema 4D SDK s26 c++
    4
    0 Votes
    4 Posts
    656 Views
    i_mazlovI
    Hello @pchg, Please note that the subject is out of scope of support as declared in the forum guidelines, namely: We cannot provide support for third party libraries. As a direction of your further investigation you can consider checking MATLAB library for using incompatible dependencies. Another guess would be to check if plugin registration succeeds at all. Thanks for your understanding! Cheers, Ilia
  • 0 Votes
    4 Posts
    1k Views
    ferdinandF
    Hello @derekheisler, 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 follow the idea of keeping things short and mentioning your primary question in a clear manner. About your First Question Please excuse the slight delay and thank you for the community answer provided by @HerrMay. The core misconception in your code lies in the line objs = doc.GetObjects(), as it does not get a list of all objects in doc, but only the root level objects. Users are expected to do scene graph traversal on their own at the moment, there is no method which would do it for you. There are also other problems with your code, as for example trying to instantiate a BaseThread or using CallCommand (not a real problem but not recommended in most cases). There have been also multiple similar threads in the past: How do you collapse complex dependencies in order?: This is about implementing a connect and delete. How to traverse a GeListNode Tree?: This is about hierarchical traversal, i.e., getting all descendants and siblings for a node. There is also something that I would call branch traversal, it is much more complex and we have talked about it for example here. CAD Normal Tag flipped: Entirely different topic, but could give you an idea on how to realize a simple GUI for this. Finde below a simple example. Cheers, Ferdinand Result: [image: 1680193792635-collapse.gif] Code: """Demonstrates how to collapse all SDS objects in a scene. One could also make this more fancy with a GUI and undo steps, I did not do this here. """ import c4d doc: c4d.documents.BaseDocument # The active document. def IterNodes(node: c4d.GeListNode) -> c4d.GeListNode: """Yields all descendants and next-siblings of `node` in a semi-iterative fashion. """ if node is None: return while node: yield node # The recursion moving down. for descendant in IterNodes(node.GetDown()): yield descendant # The iteration in one level. node = node.GetNext() def Collapse(objects: list[c4d.BaseObject]) -> None: """Collapses all items in #objects as individual root nodes into singular objects. This function mimics the behaviour of the builtin (but unexposed) "Connect & Delete" command by first running the "CSTO" and then "JOIN" command. With setups complex enough, this can still fail due to the non-existent dependency graph of the classic API (when one does CSTO things in the wrong order). In 99.9% of the cases this will not be the case, but one should get the inputs with #GETACTIVEOBJECTFLAGS_SELECTIONORDER as I did below to give the user more control. (or alternatively do not batch operate). """ if len(objects) < 1: raise RuntimeError() doc: c4d.documents.BaseDocument = objects[0].GetDocument() doc.StartUndo() # CSTO all local hierarchies in #objects and replace these root nodes with their collapsed # counter parts. result = c4d.utils.SendModelingCommand(c4d.MCOMMAND_CURRENTSTATETOOBJECT, objects, c4d.MODELINGCOMMANDMODE_ALL, c4d.BaseContainer(), doc, c4d.MODELINGCOMMANDFLAGS_NONE) if not result or len(result) != len(objects): raise RuntimeError() for old, new in zip(objects, result): parent, pred = old.GetUp(), old.GetPred() doc.AddUndo(c4d.UNDOTYPE_DELETEOBJ, old) old.Remove() doc.InsertObject(new, parent, pred) doc.AddUndo(c4d.UNDOTYPE_NEWOBJ, new) # Join the CSTO results root by root object, and then replace the CSTO results with the final # collapsed result. JOIN is a bit weird when it comes to transforms, so we must store the # transform of the to be joined object, then zero it out, and finally apply it to the joined # result again. for obj in result: mg: c4d.Matrix = obj.GetMg() obj.SetMg(c4d.Matrix()) joined = c4d.utils.SendModelingCommand(c4d.MCOMMAND_JOIN, [obj], c4d.MODELINGCOMMANDMODE_ALL, c4d.BaseContainer(), doc, c4d.MODELINGCOMMANDFLAGS_NONE) if not joined: raise RuntimeError() parent, pred = obj.GetUp(), obj.GetPred() doc.AddUndo(c4d.UNDOTYPE_DELETEOBJ, obj) obj.Remove() new: c4d.BaseObject = joined[0] new.SetMg(mg) doc.InsertObject(new, parent, pred) doc.AddUndo(c4d.UNDOTYPE_NEWOBJ, new) doc.EndUndo() c4d.EventAdd() def main() -> None: """Runs the example. """ # Find all SDS objects in the scene. objectList: list[c4d.BaseObject] = [ n for n in IterNodes(doc.GetFirstObject()) if n.CheckType(c4d.Osds)] # Collapse all SDS objects we have found. for obj in objectList: # We have to check if #obj is still a valid reference because we could have already # collapsed the object away in a prior iteration; sds-objects can live inside sds-objects. if not obj.IsAlive(): continue # Collapse the object. Collapse([obj]) c4d.EventAdd() if __name__ == "__main__": main()
  • 0 Votes
    4 Posts
    752 Views
    ferdinandF
    Hello @HerrMay, Is the multiplication of a matrix with a vector (mg.off = mg * p) essentially the same what mg * c4d.utils.MatrixMove(vec) does? No, mg * p multiplies a matrix by a vector which will yield the transformed vector p'. mg * c4d.utils.MatrixMove(vec) on the other hand multiplies two matrices, yielding the combined transform of them, a new matrix. What would be equivalent to mg * p is mg * c4d.utils.MatrixMove(p) * c4d.Vetcor(0, 0, 0). Please note that the whole subject is also out of scope of support as declared in the forum guidelines. I understand that the subject is a common barrier for the more on the artist-sided leaning users of ours, and I help where I can, but we cannot teach you vector math, linear algebra, or however you want to label this subject. Find below a short code example. Cheers, Ferdinand Output: M = Matrix(v1: (1, 0, 0); v2: (0, 1, 0); v3: (0, 0, 1); off: (0, 100, 0)) p = Vector(100, 0, 0) M * p = Vector(100, 100, 0) M * c4d.utils.MatrixMove(c4d.Vector(100, 0, 0)) = Matrix(v1: (1, 0, 0); v2: (0, 1, 0); v3: (0, 0, 1); off: (100, 100, 0)) M * c4d.Vector(100, 0, 0) = Vector(100, 100, 0) N * c4d.Vector( 0, 0, 0) = Vector(100, 100, 0) M * c4d.utils.MatrixMove(p) * c4d.Vector(0, 0, 0) = Vector(100, 100, 0) Code: import c4d # Let us assume #M to be the global matrix/transform of some object #op. View it as a tool to # transform a point in global space into the local coordinate system of #op. M: c4d.Matrix = c4d.Matrix(off=c4d.Vector(0, 100, 0)) # The matrix #M now has this form: # # | v1 1 0 0 | # The "x-axis" of the coordinate system defined by #M. # | v2 0 1 0 | # The "y-axis" of the coordinate system defined by #M. # | v3 0 0 1 | # The "z-axis" of the coordinate system defined by #M. # ---------------------- # | off 0 100 0 | # The origin of the coordinate system defined by #M. # # I.e., #M has the standard orientation and scale and only translates all things by 100 units # on the y-axis. So, the object #op would have the Euler angles (0°, 0°, 0°), the scale (1, 1, 1) # and the position (0, 100, 0) in world coordinates. # Define a vector #p to transform and print both #M and #p. p: c4d.Vector = c4d.Vector(100, 0, 0) print(f"{M = }") print(f"{p = }") # Transforming a point #p by a matrix #M will yield a point #q that is in the same relation to #M # as #p is to the global frame. q: c4d.Vector = M * p # #q will be the vector (100, 100, 0) because , (100, 100, 0) and #M are the same relation as #p # and the identity matrix are, a.k.a., the world frame. In a less technical way, (0, 100, 0) is the # origin of the coordinate system defined by #M. And to express #p in a manner as if #M would be # its coordinate system, we have to add (0, 100, 0), because that is the new origin. For orientation # and scale it works more or less the same, I would recommend having a look at the Matrix manual or # Wikipedia article on the subject. print (f"{M * p = }") # We can construct new transforms in many ways (again, Matrix Manual :)), one of them is by # combining multiple transforms via matrix multiplication. # We "add" the translation transform (100, 0, 0) to #M. Note that matrix multiplication is not # commutative, i.e., "M * N = N * M" does not always hold true. In this case it would because only # translations are involved. N: c4d.Matrix = M * c4d.utils.MatrixMove(c4d.Vector(100, 0, 0)) print(f"{M * c4d.utils.MatrixMove(c4d.Vector(100, 0, 0)) = }") # To get the same point as #q when multiplying a point #r with #N, we must pick the null-vector # because the origin of #N is already at where M * (100, 0, 0) is. print (f"{M * c4d.Vector(100, 0, 0) = }") print (f"{N * c4d.Vector( 0, 0, 0) = }") # We can also do it in one operation: print (f"{M * c4d.utils.MatrixMove(p) * c4d.Vector(0, 0, 0) = }")
  • 0 Votes
    4 Posts
    642 Views
    M
    Hello @HerrMay, without further questions or postings, we will consider this topic as solved by Monday 05/06/2023 and flag it accordingly. Thank you for your understanding, Maxime.
  • 0 Votes
    3 Posts
    426 Views
    H
    Hi @m_adam, alrighty, good to know that this will be looked into and eventually get fixed. Yes, I remember I returned True in the past. In the python tag as well as in the TagData equivalent. As returning super didn't work. Thanks for the information anyway. Cheers, Sebastian
  • 0 Votes
    3 Posts
    650 Views
    H
    Hi @m_adam, thanks for the explanation and your example code. That will absolutely suffice my needs. Good to know though that additional information may be available in the future. Cheers, Sebastian