• Simulating mouse movement in C4D

    Cinema 4D SDK python r25 windows
    5
    0 Votes
    5 Posts
    3k Views
    D
    Hi @ferdinand, Thank you so much for the comprehensive reply! Given all this I don't think it would make sense to keep trying to unit test this particular part of our code with Python. The last approach you highlighted with testing directly on the C++ side seems like the best option, so I'll give that a try. I'll have to see how to integrate this test with the rest of the unit tests (we have a lot and they're all in Python) but hopefully that won't be too much of a problem. Thanks again for all the help, Daniel
  • Can't snap to Generator output spline

    Cinema 4D SDK r25 python windows
    4
    0 Votes
    4 Posts
    982 Views
    ferdinandF
    Hey @Madara, in short, a Python generator object is not meant to generate splines. You can collapse the cache of your constructed spline and return its LineObject cache instead of the spline itself. For an example, see [1]. In your case that would be connect_obj. This will work in the sense that the generator cache will be then like a SplineObject cache and when you 'Current State to Object' your generator, it will behave like a spline and give you the interpolated editable linear spline and not a spline generator. However, spline snapping not only inspects caches, but also checks if OBJECT_ISSPLINE is true. So, you cannot bamboozle it by faking a SplineObject cache. You will have to implement a proper spline plugin for what you want to do, as you can overwrite there GetContour Cheers, Ferdinand PS: Your code contains multiple elements that can crash Cinema 4D and/or corrupt the loaded document. Specifically, these sections: if link_clone: #Parametric object pobj = u.SendModelingCommand( command = c4d.MCOMMAND_CURRENTSTATETOOBJECT, list = [connect_obj], mode = c4d.MODELINGCOMMANDMODE_ALL, doc = op.GetMain()) connect_obj = pobj[0] ... offspline = u.SendModelingCommand( c4d.MCOMMAND_SPLINE_CREATEOUTLINE, [connect_obj], c4d.MODELINGCOMMANDMODE_ALL, bc=settings, doc=doc) A Python generator's main() function is subject to the threading restrictions of Cinema 4D because it is just a wrapper for ObjectData.GetVirtualObjects. Executing SendModelingCommand in a threaded context is fine, but you cannot do it on the active document (both doc and op.GetDocument() are the active document). This is here even worsened by the fact that that the objects in list are not actually part of the document you pass as doc. To circumvent that you must create your own document just as I have in [1] with temp. Find a more detailed example of that technique in smc_extrude_s26.py. [1] import c4d op: c4d.BaseObject # The Python generator object. def main() -> c4d.BaseObject: """ """ # A user data Boolean to toggle collapsing the cache of this generator. collapse: bool = op[c4d.ID_USERDATA, 1] spline: c4d.BaseObject = c4d.BaseObject(c4d.Osplinecircle) if not spline: return c4d.BaseObject(c4d.Onull) # Just return the circle spline itself when #collapse is false. if not collapse: return spline # Otherwise grab the LineObject cache of the spline and return a copy of it. temp: c4d.documents.BaseDocument = c4d.documents.BaseDocument() temp.InsertObject(spline) temp.ExecutePasses(c4d.threading.GeGetCurrentThread(), False, False, True, c4d.BUILDFLAGS_NONE) cache: c4d.LineObject | None = spline.GetCache() if not isinstance(cache, c4d.LineObject): return c4d.BaseObject(c4d.Onull) return cache.GetClone(c4d.COPYFLAGS_NONE)
  • abc exported object names

    Moved Bugs r25 python
    3
    2
    1 Votes
    3 Posts
    1k Views
    S
    super, thanks
  • 0 Votes
    5 Posts
    1k Views
    fwilleke80F
    @jana sorry, I forgot to flag it myself. All solved, thank you
  • 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()
  • Getting rid of the burger icon in a dialog

    Cinema 4D SDK r25 c++
    12
    0 Votes
    12 Posts
    2k Views
    fwilleke80F
    Woot, it works!
  • TreeView DropDown Menu

    Cinema 4D SDK
    3
    0 Votes
    3 Posts
    1k 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
  • Detect CTRL + RightMouseButton in SceneHook

    Cinema 4D SDK r25 c++ 2023
    3
    0 Votes
    3 Posts
    802 Views
    C4DSC
    Thanks for taking the time to respond, even during the weekend. I must say this is quite embarrassing: I already had forgotten about the response in the other thread, and it's not even 3 weeks old. I sincerely apologize for wasting your time with this duplicate thread. I can confirm the GetInputState is working fine, no need to waste more of your time trying it out. Thanks again.
  • PointObject.CalcVertexMap(self, modifier)

    Cinema 4D SDK python r25
    5
    0 Votes
    5 Posts
    1k Views
    A
    @m_adam hi Maxime, thank you for your availability. Bacca's answer immediately cleared my mind on the subject, just as I was reading the other thread. I usually use the traditional method of calculating vertexmaps in the presence of obstacles. I thought CalcVertexMap did just that (the restriction tag is not mentioned in the SDK, so I couldn't figure out how to use it) but my curiosity is just didactic. Ciao Gianluca
  • Removing IsolateObjects document

    Cinema 4D SDK r23 r25 c++ 2023 r20
    3
    0 Votes
    3 Posts
    864 Views
    ManuelM
    hi, yes, KillDocument is not necessary in that case. Cheers, Manuel
  • How to detect CTRL being pressed in a GeDialog

    Cinema 4D SDK r23 r25 2023 c++
    4
    0 Votes
    4 Posts
    1k Views
    C4DSC
    Thanks @m_adam I can confirm that the following does work with R20, R23 and 2023 Int32 MyDialog::Message(const BaseContainer& msg, BaseContainer& result) { BaseContainer keyChannels; if (GetInputState(BFM_INPUT_KEYBOARD, QCTRL, keyChannels)) { Bool ctrlModifier = (keyChannels.GetInt32(BFM_INPUT_QUALIFIER) & QCTRL) != 0;
  • Tree-Generator

    Moved General Talk r25
    8
    1
    0 Votes
    8 Posts
    4k Views
    R
    @love_me_render Thank you very much
  • Keyframing the source file on an ImageTexture shader

    Cinema 4D SDK r25
    3
    0 Votes
    3 Posts
    736 Views
    mocolocoM
    Hi, A simple addition on CTrack and DescId as I was also faced to this a time ago. You can consult the @ferdinand's explanations and exemples on CTrack to the following post : https://developers.maxon.net/forum/topic/14315/solved-how-to-setup-a-ctrack-on-tag-plugin-ui-slider-with-extended-details/8 Cheers, Christophe
  • Set PYP file syntax highlighting in VS Code?

    General Talk r25 python
    4
    0 Votes
    4 Posts
    1k Views
    M
    Btw if you install the Cinema 4D Vs Code extension, pyp extension should be added as Python.
  • Implement A Usage Counter?

    General Talk python r25
    3
    0 Votes
    3 Posts
    667 Views
    B
    @ferdinand Thanks for the pointers. I'll try to look up those options. Will close this thread now.
  • Add Additional Script Path?

    General Talk r25 python
    3
    0 Votes
    3 Posts
    613 Views
    B
    @m_adam Thanks for the response. Modifying the environment varialbles works for my use case. Closing the thread now.
  • Compiling for R20... linker error in maxon::String

    Cinema 4D SDK r20 r25 c++
    5
    0 Votes
    5 Posts
    1k Views
    M
    Hello @fwilleke80 , without further questions or postings, we will consider this topic as solved by Thursday 01/06/2023 and flag it accordingly. Thank you for your understanding, Maxime.
  • Actively Link Hair Guides to a Spline or Alembic?

    Cinema 4D SDK r25 python
    3
    0 Votes
    3 Posts
    694 Views
    B
    Hi @ferdinand Thanks for the response and heads up on the crashes. RE: you want to control hair guide vertices programmatically Yep yep you are right on this part. Basically, have a geometric hair animated and simulated for preview. But rendered on the actual hair object. This is the workflow for other DCC, and the more logical one. This way you separate the hair source and hair generation. It's easier to debug. Anyhow, for looking at your python example, this should get me by on my current use case. Thanks for your illustration as always! Will close thread now.
  • Node Method IsValid() Throws ValueError

    Cinema 4D SDK python r25
    5
    0 Votes
    5 Posts
    501 Views
    B
    @m_adam Gotcha. Thanks for the heads up!
  • Swap Out Joint Axis Rotation?

    Cinema 4D SDK r25 python
    7
    0 Votes
    7 Posts
    668 Views
    B
    @manuel Interesting. Thanks for the heads up. It works now as expected. Closing the thread.