• Gradient Interpolation Error in 2024 release

    python 2024
    3
    0 Votes
    3 Posts
    619 Views
    D
    @m_adam Brilliant! Thanks a lot!
  • Running Automatic UV for all objects

    python windows
    3
    1
    1 Votes
    3 Posts
    1k Views
    M
    Hi @BineeMan sorry for the late reply I was pretty busy Friday and thanks @Dunhou for demonstrating how Packed Auto UV work. For Cubic and Angle you need to use c4d.modules.bodypaint.CallUVComman as demonstrated in the call_uv_command_ example. So for the Angle automatic UV you need to use the command ID c4d.UVCOMMAND_OPTIMALMAPPING with the next parameters: c4d.OPTIMALMAPPING_PRESERVEORIENTATION # Preserve Orientation c4d.OPTIMALMAPPING_STRETCHTOFIT # Stretch to Fit c4d.OPTIMALMAPPING_DISTORTION # Maximu, Distortion c4d.OPTIMALMAPPING_RELAXCOUNT # Relaxation Steps c4d.OPTIMALMAPPING_SPACING # Spacing And for the Cubic automatic UV you need to use the command ID c4d.UVCOMMAND_OPTIMALCUBICMAPPING with the next parameters: c4d.OPTIMALMAPPING_PRESERVEORIENTATION # Preserve Orientation c4d.OPTIMALMAPPING_STRETCHTOFIT # Stretch to Fit c4d.OPTIMALMAPPING_TWOD # 2D c4d.OPTIMALMAPPING_AREAFAK # Maximum Area Factor c4d.OPTIMALMAPPING_RELAXCOUNT # Relaxation Steps c4d.OPTIMALMAPPING_SPACING # Spacing Cheers, Maxime.
  • 2024 Conversion questions

    2024 c++
    2
    0 Votes
    2 Posts
    561 Views
    ferdinandF
    Hey @Rox, Thank you for reaching out to us. You really should have a look at the migration guide, as these topics are covered there. We cannot debug every compiler error here for you, nevertheless here are the answers to your three problems: // 1 - That should fix it as the signature is now: // GeData( const CustomDataType & data, Int32 type ) t_data = GeData(bbs, CUSTOMDATATYPE_BITMAPBUTTON); // 2 - Selections are now COW and make a distinction between being mutable and immutable. const BaseSelect* const mySelection = sTag->GetBaseSelect(); // immutable BaseSelect* const mySelection = sTag->GetWritableBaseSelect(); // mutable // 3 - Same story here, GetCustomDataType returns immutable data now, the method is also templated // now, so you do not need to cast things anymore. const InExcludeData* const myList= bc->GetCustomDataType<InExcludeData>(MY_ID); InExcludeData* const myList= bc->GetCustomDataTypeWritableObsolete<InExcludeData>(MY_ID); Cheers, Ferdinand edit: forgot the template argument in BaseContainer::GetCustomDataType
  • Dynamically changing custom icon of TagData Plugin

    python s26 windows
    6
    2
    1 Votes
    6 Posts
    1k Views
    ferdinandF
    Hello @HerrMay, Thank you for the updated information. I had a look at your problem, and I could reproduce it, but it is primarily a problem of your code as suspected. I document below how I analyzed this problem not as a passive aggressive expression of "look how easy that is!". But to give an insight on how to approach such debugging task. The core rule is here to question one's own assumptions and assure that things are indeed how we think they are. Debugging So, when one follows your steps, one indeed ends up with something like this: [image: 1694702115621-8fdef1aa-1a5e-43d8-8cdb-42b480fd4f0d-image.png] Your assumption here was that the icon handling is bugged on our side. For that to be true, the tag on Null.2 would have to be IDC_ACTIVE_ON but with the icon handling failing and Cinemas 4D rendering it as disabled. So, I checked the value with this code: # Set custom icon for node. if id == c4d.MSG_GETCUSTOMICON: host: c4d.BaseObject = tag.GetObject() isFirst: bool = host.GetUp() == None and host.GetPred() == None if isFirst: print(f"TOP: {host.GetName() = }, {tag[IDC_ACTIVE] = }") else: print(f"OTHER: {host.GetName() = }, {tag[IDC_ACTIVE] = }") icon = self.PLUGIN_ICON_INACTIVE if tag[IDC_ACTIVE] == IDC_ACTIVE_OFF else self.PLUGIN_ICON_ACTIVE data["bmp"] = icon data["w"] = icon.GetBw() data["h"] = icon.GetBh() data["filled"] = True Which will print this when you add the tags: [image: 1694702486106-baebed6a-fdc0-4d53-8214-1d6b2011cad8-image.png] So, the topmost tag is indeed inactive and the icon rendering is correct. The question is now: 'Why is that tag inactive because we initialize all tags as node[IDC_ACTIVE] = IDC_ACTIVE_ON ?' The likely culprit is just a few lines above, as we toggle there the active state of our tag. # Handle double click on tag. if id == c4d.MSG_EDIT: if tag[IDC_ACTIVE] == IDC_ACTIVE_OFF: tag[IDC_ACTIVE] = IDC_ACTIVE_ON else: tag[IDC_ACTIVE] = IDC_ACTIVE_OFF And indeed, when we comment out these lines, we end up with this when creating multiple new tags. [image: 1694702820259-ebddd8e2-ff78-47f3-a4ca-40cbd26ac047-image.png] Moreover, when we revert our change of commenting out that code and test our assumption 'only happens for multi-object selections', we can see that this does not hold true: [image: 1694703033146-e5f2a8dd-2ebd-4555-8188-d769b84895e3-image.png] We can now check our own comment: # Handle double click on tag. if id == c4d.MSG_EDIT: ... and check MSG_EDIT: [image: 1694703119443-de39ee11-81d9-4e68-a2a6-a4c4dd182b84-image.png] The documentation says, "for example". So, the event does not capture a double click, but double clicking a BaseObject to edit its name is one example of an edit event. Adding a tag to an object apparently also emits MSG_EDIT to the tag, and when you have a multi-selection, MSG_EDIT is only emitted to the first element in the selection. Conclusion That behavior of MSG_EDIT in regard to tags and multi-selections is of course quite odd, but I would not consider it to be a bug, as an edit event is not really defined for tags in the first place. And while I understand what you want to do here, I would also say that what you do in MSG_EDIT is a violation of the UX principles of Cinema 4D. Double clicking a tag should not edit a random parameter in it. We strive for Cinema 4D having a seamless UX-experience for users including plugins. So, we rather not support it when plugin authors are trying to break these UX rules. But I will nevertheless talk with my colleagues about the subject and if we want to consider this behavior of MSG_EDIT to be a bug. Cheers, Ferdinand
  • Can't snap to Generator output spline

    r25 python windows
    4
    0 Votes
    4 Posts
    739 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)
  • GetDefaultValue Not Working in C4D 2024

    python
    3
    0 Votes
    3 Posts
    530 Views
    E
    @m_adam I'm looking forward to the next version update. Thank you for your response.
  • Converting ABC file to AEC using c4dpy?

    windows python
    3
    0 Votes
    3 Posts
    456 Views
    S
    Hi Maxime, thanks for the information - so just to clarify, I need to use RDATA_PROJECTFILESAVE in order to export as an AEC?
  • Script path instead of call command in Python

    2023 python
    2
    0 Votes
    2 Posts
    541 Views
    ferdinandF
    Hello @specnazspe, 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 Command IDs are assigned dynamically to a script and therefore can change. It seems also a bit overly complicated to have a tag that evaluates user data interactions on its host to call a command wrapping a script. Commands are based on IDs, so you cannot pass them a script path, but Python itself has one million and one way to have Python code execute other Python code. Since you want to use the content of your script just as a library, you should make it one. Place the logic of it in a library apth of your liking and import that logic both into your Script manager script and Python tag when needed. You could use the std lib function runpy to run the code found at a script path yourself. Basically, what I did in run_script here. Find here the matching thread. You could also just manipulate sys.path from your tag to inject the path where your script lies, so you can then import the script like a module. I would not recommend doing point 2 or 3 because they are both error prone. Just expose the commonly used functionality used both by the script and tag as a lib. edit: As pointed out by @m_adam, since S26, you can also evaluate the dynamic ID of scripting objects from Python. Finde an example in load_python_script_r26.py. The bread and butter of this is c4d.GetDynamicScriptID. Cheers, Ferdinand
  • 0 Votes
    5 Posts
    800 Views
    F
    @m_adam OK. Thank you very much. Cheers
  • Nesting Pivot object causes parent to shoot up into space

    6
    0 Votes
    6 Posts
    866 Views
    ferdinandF
    Hey @HerrMay, Great to hear that you solved your problem. Cheers, Ferdinand
  • How can I use Plane Cut in Python

    python 2023 windows
    3
    0 Votes
    3 Posts
    603 Views
    C
    Thank you very much! Now it is working.
  • urllib.request module is missing

    5
    0 Votes
    5 Posts
    1k Views
    B
    @ferdinand Brilliant, thank you.
  • Can I use both MouseDown() and DoubleClick() in treeview?

    python windows 2023
    3
    0 Votes
    3 Posts
    588 Views
    DunhouD
    Hi @ferdinand , @ferdinand said in Can I use both MouseDown() and DoubleClick() in treeview?: In general, you should keep in mind that the concept of a double click is only represented very weakly in Cinema 4D, with TreeViewFunctions being one of the very few cases which uses that term. In the backbone of the API, the GUI message stream, the concept of a double click does not exist. Things are actions (BFM_ACTION_...) and inputs (BFM_INPUT_...) and each mouse click counts as an input and/or action. It is up to specific gadgets to bundle up multiple clicks into a double click. That helps foe better unstand how it worked, thanks! And this kind solution is a much more mature solution than what I used a simple one in my Octane Light Manager, I try to stop the set check event duplicate many times, I will keep more condition as your suggestion. [image: 1693920299018-e0be12a8-f277-400d-9d7a-14065e55ffee-image.png] Thanks again for your detailed explain for all the answer. Cheers~ DunHou
  • delete vertex from quad-poly delets the poly

    Moved
    6
    2
    0 Votes
    6 Posts
    1k Views
    D
    @ferdinand thanks for your explanation and sorry for the ambiguouty! the second image showed what currently happens, but not what i wanted. so converting a quad to tri is more like reordering the verticies and leaving one out. makes sens. hope i find the time to test it next weekend ... finding the points is already done, but thanks for the hint. most of the time i use a little trick: select all points, shrink selection, grow selection. then points, that were only connectet to two border-verticies will not be reselectet, you can invert the selection and have the points. but border-points of n-gons will be selectet too. for these i do have a script that makes use of the neighbor function. 1.2.2. yes i'm aware of the right-angled quad cases, and luckily they don't matter in my case. but thanks for pointing it out. i find it super cool how alert you are! appreciate it alot.
  • Can't install pygrib module

    2
    1
    0 Votes
    2 Posts
    302 Views
    M
    Hi @peteclear, my recommendation would be to install Cinema 4D again on another directory, to be sure you did not forget any reference to Vray. Think about environment variable that may force cinema 4d to load Vray from some other locations. If this does not solve you can run the same command with the python interpreter located in {C4D_INSTALLATION_PATH}\resource\modules\python\libs\python37.win64.framework. Make sure to have Cinema 4D closed when you run it, once done you should be able to start Cinema 4D and use your 3rd party library. Final note, R23 is out of support scope and installing pip packing with the second method I mention is not recommended since this is untested, so some part of the installed modules may not work. Cheers, Maxime.
  • Registration code being run in After Effects

    4
    0 Votes
    4 Posts
    687 Views
    i_mazlovI
    Hi Timm, You can familiarize yourself with cineware integrations on our documentation webpage Maxon Cineware User Guides. Specifically for the After Effects integration there's a compact but rather informative description (as well as pointers to a corresponding video footages at Maxon's Youtube channel) on a dedicated webpage Cineware for After Effects: Adobe After Effects includes a free installation of Cinema 4D Lite – a limited but feature rich version of Maxon’s award-winning 3D software package. Cinema 4D Lite can be accessed directly from within After Effects in the File ⇒ New menu, or by clicking Edit Footage on a Cinema 4D layer in your composition. The question about proper licensing behavior of your plugin lies outside of scope of knowledge and highly depends on the goals you're trying to achieve. As I already pointed out, say, the scene with some object defined in the external plugin would require this plugin to be loaded by cineware as well to function the same way as in C4D. Cineware integrations use preferences folder different from the one that is used by Cinema 4D (it uses the same folder name with suffix _w). Hence, all the preferences (including the world container) are not shared between C4D and Cineware. The behavior of some function call can also differ, including GetGeneralLicensingInformation(). However, the system identifier systemId is independent of the APPLICATIONID and will be the same in both cases. Let me know if you have any further questions. Cheers, Ilia
  • Problem with plugin example

    2023 python
    7
    0 Votes
    7 Posts
    1k Views
    ferdinandF
    Hey @filipst, please adhere to our rule for a topic being a singular subject/line of questioning. I strongly doubt that Current State to Object (CSTO) and Make Editable (ME) were ever the same for splines; and if so, this was probably a bug. There is a fundamental difference between these two operations. Current State to Object: Collapses the cache of the entity it is being called upon and inserts it into the scene. Make Editable: Replaces an object with its (direct and uncollapsed) cache. Aside from the obvious difference that CTSO produces a new object and ME replaces its input, there is a fundamental difference in getting the cache of something (ME) or getting the collapsed cache of something (CSTO). Caches tend to be hierarchical structures in Cinema 4D and can become very complex. A simple example would be to collapse a spline with a bend deformer attached to it. Input: [image: 1693570672626-735753e6-3276-4ae8-b19a-369d5e9aaf01-image.png] Make Editable output (with deformer disabled for clarity): [image: 1693571275301-c20a09cd-83a4-47c4-bd4c-7dd774733144-image.png] CSTO output: [image: 1693571349405-787e44c3-bb86-4efd-9633-94271266326d-image.png] I went over the topic of caches and our geometry model here. For this hierarchy, [image: 1693571575544-5bb9fe31-178b-4967-821f-ebfccb153e47-image.png] the Circle object will have a cache tree as follows: + 1: Circle (BaseObject Generator) + 2: Cache of 1: Circle (SplineObject Generator) + 3: Cache of 2: Circle (LineObject) + 4: Deform Cache of 3: Circle (LineObject) The Circle object is a BaseObject generator which has a SplineObject as its cache which itself is a generator and has a LineObject as its cache (i.e., the discrete representation of the spline for its current interpolation settings). The bend deformer deforms this terminal node in the cache chain, the LineObject, and not the SplineObject. CSTO collapses the whole cache of an object, i.e., exhausts it. In this case this means returning 4, which includes deformation and the Bezier spline converted to its linear spline representation. CSTO can also mean joining objects in a cache, which is not represented by this simple example. ME on the other hand returns 2, i.e., whatever is the direct cache of the entity it has been invoked on. We do not collapse the cache of the cache and therefore neither include the LineObject cache nor its deform cache (they are of course still implicitly generated as the cache for the SplineObject we return because ME replaces its input object). Cheers, Ferdinand
  • Tag plugin general issues (crash, threading, message)

    r23 2023 python windows
    4
    0 Votes
    4 Posts
    804 Views
    ThomasBT
    @ferdinand Thank you Ferdinand for your leniency regarding the three questions.. Will take note of that in the future. =====BaseTime===== Which just surprises me about the BaseTime problem is, that it worked in the Python tag. I didn't get an error message and the prototype worked very well. So I also tried instead of BaseTime int type value in the plugin, but it crashed. It confused me a bit. So I try your suggestion. # In the python tag it worked with int # starf_frame was an int frame = doc.GetTime().GetFrame(doc.GetFps()) - op[c4d.ID_USERDATA,start_frame] ====PoseMorph Symbol==== Regarding the posmorph ID, I should have figured that out myself Thanks for your quick respond Tom
  • Very Slow - AddUndo() Before Removing Object From the Document

    python 2023
    2
    0 Votes
    2 Posts
    468 Views
    i_mazlovI
    Hello @wuzelwazel, Depending on the size and complexity of objects on your scene (namely on the objects that are processed with the script) adding an undo can be quite an expensive operation to execute. There was some recent work done that should affect the undo-stack in a positive way in the following releases. Let me know if you have any further questions. Cheers, Ilia
  • Calculate Rigid Transform Matrix to match two identical objects

    10
    0 Votes
    10 Posts
    2k Views
    HerzogVonWieselH
    @ferdinand you are amazing! Thank you so much for your help, this is it. Now only remains the last step until my script to automatically recognize and replace duplicate objects with instances is complete: The UI. But that should be a quick one. Thank you so much for your help again Ferdinand, you are a saint. Have a superb week and best wishes from Potsdam! Jerome