• Trigger Autosave

    python
    3
    0 Votes
    3 Posts
    485 Views
    H
    Hi Ferdinand, No worries! Thanks for the reply, it was very helpful as a starting point. I ended up using the c4d.GetWorldContainerInstance() and then c4d.WPREF_AUTOSAVE_DEST_PATH to get the custom filepath and then just a SaveDocument with the AUTOSAVE flag seems to be doing the trick. thanks again!
  • Faster way of converting dict of Vector3 to Vector4

    python
    3
    0 Votes
    3 Posts
    648 Views
    orestiskonO
    @m_adam Thanks a lot for the benchmarking Maxime. I was planning to go for the string method, I'm surprised it's not faster. I wasn't planning to use this for a plugin, not to mention C++, but it's good information to have.
  • update background color of bitmap button and static text

    2
    0 Votes
    2 Posts
    419 Views
    ManuelM
    Hi, it's not possible to change the backgrounds of those gadgets. For the button, you can instead add a BitmapButton and change the image to display the color you want just like in this thread Cheers, Manuel
  • MoData Effector Rotation

    r20 c++ sdk
    8
    1
    0 Votes
    8 Posts
    1k Views
    ferdinandF
    Hello @johnterenece, so, to clarify this for myself. You have an ObjectData implementation which probably overwrites GetContour, i.e., builds a SplineObject , or draws spline-like information into the viewport. This plugin then has an InExcludeData parameter which is populated with Mograph effectors which are then meant to influence the vertices of your plugin. Consequently you want to do the deformation of your input geometry yourself and not like I assumed before not just clone stuff onto a PolygonObject that has been deformed by a PolyFx. First of all, I do not see really the point in reinventing the wheel in the first place, why not use PolyFX if it does what you need anyways? I would also stress that this cobling up of functionalties, deformation and generation in your case, in a single plugin and even single function in your case, is often not a very good idea, bot for technical and debugging reasons. As I said before, we cannot debug your code for you, but here are some points: The way you use a MoData tag is not its intended usage, the tag is reserved for MoGraph generators only and you hijacking it here is something you have to do on your own responsiblity. You also do not take the transforms of the effectors into account which might be a cause for your problem. There are other problems like using BaseObject::MakeTag and a possibly thread environment and the lack of error handling with maxon::BaseArray::Append which can lead to crashes, as you just store posible erros in resultVector and resultVector2D in your code which are undefined, but I assume to be of type maxon::Result<Vector> and maxon::Result<maxon:BaseArray<Vector>. But they are not the source of your problem, which likely lies in the fact that you do hijack MoData in the way you do and then do not respect the transforms of the effectors. You still have not told us the plugin type you are implementing, but if it is a ObjectData which generates a spline, I would simply build the spline on the orginal polygon geometry and then retun the spline with a PolyFX attached to it in GetContour. Much easier than reinventing the wheel here. You would have to pass through the content of the InExcludeData of your plugin to the PolyFX. Cheers, Ferdinand
  • 0 Votes
    8 Posts
    1k Views
    ManuelM
    Hi, I'm happy that you solved your issue. For your next post, and i know you can see that as a waste of time, please follow our guidelines. Use the functionalities of the forum to mark your thread as a question, and mark it as solved when it's done. (Even for a negative answer). Please use also tags, that help us to understand and answer faster without guessing. Language you are using (python, c++) cinema4D version, everything that can help us to understand your issue. You will also find on those guidelines how to explain your issue. Sometimes people want a solution for an issue creating by a bad workflow. In your case, it looks more like sharing information between plugins. There are several answers/possibilities for that. This forum is also about stepping back, having a fresh eye on your issue and move forward Cheers, Manuel
  • R20 and R24 Description Differences

    8
    0 Votes
    8 Posts
    1k Views
    D
    @m_adam Hi! Thanks for looking into it!
  • How to hide or disable user data description elements

    python s24 windows macos
    2
    1
    0 Votes
    2 Posts
    506 Views
    ferdinandF
    Hello @thomasb, thank you for reaching out to us. Please remember to open a new thread for new questions of yours. It is fine to ask follow-up questions in a topic, but when the threshold to a new topic is being crossed, a new thread should be opened. I have done this for you here. In principle this is at least partially possible. You can determine the visibility for a user data description element with the description field DESC_HIDE, see example at the end of the posting for details. It is not possible to gray-out, i.e., disable, user data description elements. It is also a bit a case of an unusual workflow for user data, since you would have to rebuild the user data container every time you want to hide or show and element in it. You could overwrite for example message() in a Python scripting tag and then react to when a user clicks a button, drags a slider, etc. in the user data and rebuild the user data based on that. Which would give you the dynamic GUI feeling you are probably after. I have done this in the past, but more as a hack for fun to see how far I can push user data. I would not recommend doing it as it will complicate things like animation and can lead to "janky" interfaces. Being bound to the execution order of expressions can also lead to problems. If you want dynamic GUIs, you should implement a plugin. There you can overwrite NodeData.GetDDescription() to modify the description, e.g., add, remove, or hide stuff. To disable stuff, i.e., gray it out, you must overwrite NodeData.GetDEnabling(). Cheers, Ferdinand """Example for adding a hidden user data element. """ import c4d def main(): """Adds a hidden check box and a visible integer element to the user data of the selected object. """ if op is None: raise ArgumentError("Please select an object for running this script.") datenDesc = c4d.GetCustomDataTypeDefault(c4d.DTYPE_BOOL) datenDesc[c4d.DESC_NAME] = "Daten" datenDesc[c4d.DESC_HIDE] = True # Element will be hidden stepsDesc = c4d.GetCustomDataTypeDefault(c4d.DTYPE_LONG) stepsDesc[c4d.DESC_NAME] = "steps" stepsDesc[c4d.DESC_HIDE] = False # Element will be visible op.AddUserData(datenDesc) op.AddUserData(stepsDesc) c4d.EventAdd() if __name__ == '__main__': main()
  • Python plugin and Linux CLR arguments

    python s24 r23
    5
    0 Votes
    5 Posts
    793 Views
    V
    Hello, Adding the path to the plugin in g_additionalModulePath fixed the issue. Thank you very much for your help.
  • How to add a Userdata child to a group via script

    8
    0 Votes
    8 Posts
    2k Views
    ferdinandF
    Hello @thomasb, @thomasb said: I prefer to use this notation.......it is ok or? motherDescId=c4d.DescID(c4d.DescLevel(c4d.ID_USERDATA,c4d.DTYPE_SUBCONTAINER,0),c4d.DescLevel(1,c4d.DTYPE_GROUP, 0)) Yes, that is okay. In fact, this most verbose form is the only form which is guaranteed to always to be sufficient when addressing a description element. But as stated earlier, the instances where that verbose form is required are quite rare; modifying a description like discussed here and addressing c4d.modules.graphview ports are in fact the only instances I can think of out of my head in the Python SDK. I personally would always gravitate towards the shorthand form, i.e., myNode[c4d.ID_USERDATA, 1] in this case, wherever possible, as the verbose form is a bit confusing to read. Cheers, Ferdinand
  • Target Tag not fixing to target

    r21 python
    8
    0 Votes
    8 Posts
    2k Views
    A
    Hi @Cairyn, Understood and works like a charm! Many thanks guys
  • Get a Deformed Point Position Over Time

    windows python s24
    7
    0 Votes
    7 Posts
    655 Views
    ferdinandF
    Hello @blastframe, yes, there is a loop in that script which is like my pseudo-code one. If they are doing the same thing is a bit a point of view. The script evaluates each frame to do something each frame, while my pseudo code evaluates all frames to do something after that. So, for clarity again as pseudo code: # Evaluate all frames and do something for each frame, i.e., what Maxime's # script does. for frame in FRAMES: for item in document: item = evaluate(item, frame) DoSomthing(item) # Evaluate all frames and after that do something, i.e., what I am proposing. # From a more abstract point of view, both are doing the same thing. The only # difference here is that we are not interested in the intermediate results, # only in updating an item with is prior state: `item = evaluate(item, frame)` for frame in FRAMES: for item in document: item = evaluate(item, frame) DoSomthing(someItem) If you say, you are fine with not respecting this than this will simplify things. And most things that impact (deform) caches, won't be impacted by that. But there are direct cases which are affected, e.g. cloth simulations, some deformers like for example the collision the deformer and more. And indirect cases like when you have a particle system whose state over three corners will impact some deformation. And yes, this is very taxing to do, because you must evaluate a lot of stuff each frame. And you will have likely to execute all passes (animation, expressions, and caches); in the end it depends on how a specific scene is setup. The performant way to do this is cache the required data yourself. Like for example the collision deformer can do it; i.e., you click a button and then all data is calculated which then later is only played back. I would not say that it is impossible to do this in Python, but you will lack some important types to store such data in Python that are exposed in our C++ API. Python is also in general not well suited for such task, due to its inherent slowness of iteration. But that does not mean that with some smart thinking you could not make it work in Python in a performant way. This all depends on what you are exactly trying to do and is more of a general complexity of an algorithm or project design question (and therefore out of scope of support). The bottom line is that your initial question of Get a Deformed Point Position Over Time might contain more complexity than anticipated by you, because it implies something is the recursive function itself and time. Which is always a pain in the *** to handle. Cheers, Ferdinand
  • Detecting a Change in Position/Rotation Keyframes from Tag

    windows python s24
    5
    0 Votes
    5 Posts
    620 Views
    ?
    @ferdinand Thank you. I'll try to cache myself.
  • SplineCustomGui settings issue

    r21 python windows
    11
    2
    0 Votes
    11 Posts
    2k Views
    ferdinandF
    You need to call NodeData.InitAttr() in NodeData.Init. E.g.: def Init(self, node): """ """ self.InitAttr(node, float, c4d.PY_TUBEOBJECT_RAD) self.InitAttr(node, float, c4d.PY_TUBEOBJECT_IRADX) node[c4d.PY_TUBEOBJECT_RAD] = 200.0 node[c4d.PY_TUBEOBJECT_IRADX] = 50.0 return True But you should check the allocation problem first, it is the most likely culprit. Se the edit in my last posting. Cheers, Ferdinand
  • HUD Text issues

    r23 python
    9
    1
    0 Votes
    9 Posts
    1k Views
    K
    Oh! sorry @fwilleke80 I misread your first message. @ferdinand, I think I got confused from the beginning. I made a copy of my code from an objectData plugin to a scenehook plugin without changing DRAWPASS to SCENEHOOKDRAW Everything is working just fine now(... except the aliasing) but the result is acceptable. [image: 1627633821978-ok.png] Thanks to both of you! Best Regards,
  • Python Cloner/Scatter plugin

    python
    4
    0 Votes
    4 Posts
    1k Views
    C
    Thanks to both of you! This helps alot! You guys are so nice and helpful
  • How to Highlight a Button

    python
    2
    0 Votes
    2 Posts
    522 Views
    ferdinandF
    Hello @Ling, thank you for reaching out to us. Please remember to open a new topic of you own when you have a question and not to hijack other topics. The exception to that rule is when you have a question that aligns exactly with a currently ongoing topic. The reason we enforce this, is so that the form remains a nicely searchable knowledge base. I have forked your question for that very reason; it did not align with the other topic. About your question: It depends on what you mean by it. You cannot modify the background color of a Button element. What you can do, is create a LONG element and define QUICKTABRADIO as its custom GUI; here is how the muscle object in Cinema makes use of this GUI element: LONG ID_CA_MUSCLE_OBJECT_STATE { SCALE_H; ANIM OFF; PARENTCOLLAPSE; CUSTOMGUI QUICKTABRADIO; CYCLE { ID_CA_MUSCLE_OBJECT_STATE_RELAX; ID_CA_MUSCLE_OBJECT_STATE_COMPRESSED; ID_CA_MUSCLE_OBJECT_STATE_EXTENDED; } } This will give you the tabs look as shown in many places in Cinema 4D. You will however need multiple elements to make this useful, as this is effectively an options group. What you could also do, is create a BITMAPBUTTON and then have different images for its normal and pressed stated. Cheers, Ferdinand
  • Modifying Scene On First Open or Before Save?

    s24 python
    5
    0 Votes
    5 Posts
    1k Views
    dskeithbuckD
    @C4DS @kbar @ferdinand - Thank you so much for the in-depth responses. @kbar I'll see if I can get my employer to pony up for a license for Call Python as that seems like the simplest root. Although, this is potentially a light enough lift that I can finally make the transition into C++ development. @ferdinand Helpful to know that I won't be able to interrupt the save process (probably a good thing from the user POV).
  • Calculation Errors and Best Practices

    5
    1
    0 Votes
    5 Posts
    913 Views
    ferdinandF
    Hello @orestiskon, well, are you experiencing "drift"? I am not 100% sure what you mean by drift, but I assume you mean just an error with that. As I lined out above, floating point error at 64 bits is usually not something you have to worry about in the scenario of what you are doing. There will be an error, but if you are only interested in visually representing something, it will be negligible when you meet the conditions I did line out above. I also do not get quite why you have to store the scale of the matrix. When you transform an input matrix with another matrix that has the scale of (1,1,1), then scale of the result will have the same scale as the input matrix, since x * 1 is still x. In general, you try to avoid doing multiple arithmetic operations in a row (see example at the end). Which is also the reason I proposed interpolations. But again, for just moving a cube around, you should be fine. Cheers, Ferdinand """Showcases the impact of doing the same calculation in 'different' ways. """ import math # List of ten 1.1's, 1.1 cannot be represented by 64 bit floats. items = [1.1] * 10 # This will amass the precision error of ten additions of a not representable # value. print (sum(items)) # This won't. print ((1.1 * 10)) # And this won't either. print (9.9 + 1.1) # One of Python's floating point tricks, fsum is addition with an error term. print (math.fsum(items)) 10.999999999999998 11.0 11.0 11.0
  • DRAGANDDROP_FLAG_FORBID

    c++ r21
    2
    1
    0 Votes
    2 Posts
    428 Views
    M
    Hi @AiMiDi, MSG_DRAGANDROP will be received when the host receive a drag, I didn't tried but I guess only dialog can react to this message. In you case you will need to set the NBIT NBIT_NO_DD like so op.ChangeNBit(c4d.NBIT_NO_DD, c4d.NBITCONTROL_SET). Cheers, Maxime.
  • how can I make popup like snap popup

    6
    0 Votes
    6 Posts
    847 Views
    L
    @m_adam I know the PLUGINFLAG_COMMAND_STICKY, but i do not know how can I judge the key down and key up in execute() called back function of the command data. Do you know a way to do this? Thanks!