• 0 Votes
    3 Posts
    394 Views
    ?
    @kbar Thank you for the reply and helpful link. And for anyone look to get this working with your Description files: (from https://c4dprogramming.wordpress.com/2013/05/10/long-cycles-with-icons-and-separator/), put the plugin ids in your Description header and this in your Description resource file: CONTAINER Omyobject { NAME Omyobject; INCLUDE Obase; GROUP ID_OBJECTPROPERTIES { LONG MYOBJECT_ICONCYCLE { CYCLE { MYOBJECT_ICONCYCLE_ITEM_0; -1; MYOBJECT_ICONCYCLE_ITEM_1~Ocube; MYOBJECT_ICONCYCLE_ITEM_2~Opyramid; MYOBJECT_ICONCYCLE_ITEM_3~1021433; } } } } -1 creates a separator.
  • Python API OpenGL Information

    Cinema 4D SDK r23 python
    7
    1 Votes
    7 Posts
    1k Views
    ferdinandF
    Hello @wuzelwazel, thank you for reaching out to us. I am sorry if I gave you the impression that this will be fixed with S24. This issue is still on our radar, but it does not have the highest priority. I am also unfortunately not a liberty to give you a time frame when this will be done. Thank you for your understanding, Ferdinand
  • 0 Votes
    16 Posts
    3k Views
    ferdinandF
    Hi, ten times slower sounds rough. It is probably because I was a bit lazy and used a lookup table (visited) to traverse the scene-graph, which is a rather expensive thing to do. Feel free to use the fixed traversal if performance becomes an issue here. Cheers, Ferdinand
  • Profiling of objects in Python 3

    Moved General Talk r23 python windows macos
    5
    0 Votes
    5 Posts
    1k Views
    M
    thank you both @a_block for enduring my beginner questions and zipit always keeping it precise and clean ,,, I managed to get an old script to run 20 times faster by just finding junk I was able to cleanup ! Even though as a beginner I sometimes do not know what I am doing this profiling helps to find stupid code! so few more scripts to cleanup.
  • Adding an Icon to a GeDialog Menu Group

    Cinema 4D SDK python sdk windows
    10
    1
    0 Votes
    10 Posts
    1k Views
    ?
    @zipit Thank you, Ferdinand, for looking into it!
  • 0 Votes
    3 Posts
    434 Views
    fwilleke80F
    Hi Manuel, thanks for the info! If smooth is set to false, the wrong positions disappear in deed. The distribution of the positions, however, is much uglier. It requires the user to change some specific attributes of the spline to make it look nice. But I think, that's ok for now. Thanks again & greetings, Frank
  • 0 Votes
    2 Posts
    436 Views
    M
    Hi thanks for the report this was already reported in Phong Tag with ObjectData and this is going to be fixed in the release after R23 SP1. Cheers, Maxime.
  • Syncing Object Property Update in ObjectData

    Cinema 4D SDK python
    3
    0 Votes
    3 Posts
    374 Views
    ?
    @zipit I'll post code with my scenes/screenshots in the future. Setting the value in MSG_DESCRIPTION_POSTSETPARAMETER fixed my issue! Wow, how do you know all of this stuff??!
  • Setting Read-Only STRING value in Description

    Cinema 4D SDK python
    3
    1
    0 Votes
    3 Posts
    376 Views
    ManuelM
    hi, Sorry for the delay of this answer, we simply missed your post. When using STRING READOUT_WIDTH { ANIM OFF; } it's important that you initialize the parameter in your Init function. Otherwise uninitialized type will be a int. At some point, the code is comparing the old value type with the new value. That's why it's waiting for a Int while you provide a Str. (feel like a bug to me) I don't see the problem using STATICTEXT or STRING. It does create the expected fields. The StaticText can't be Animated anyway, i would remove the ANIM OFF STATICTEXT PYPREFERENCE_STATICTEXT {} STRING PYPREFERENCE_STRING { } about the border around the static text you can declare the field like this in your ressource file: STATICTEXT PYPREFERENCE_STATICTEXT_BORDER {BORDER;} Cheers, Manuel
  • Python Plugin: numpy + scipy - Cinema4D R20

    Cinema 4D SDK
    6
    0 Votes
    6 Posts
    2k Views
    ferdinandF
    Hi, without further feedback, we will consider this thread as solved by tomorrow and flag it accordingly. Cheers, Ferdinand
  • 1 Votes
    4 Posts
    469 Views
    ferdinandF
    Hi, I did not really expect an answer, I just did put it up to make you guys aware. Regarding your reply, I agree with most of it and am aware that there a some hurdles to overcome in mapping C++ interfaces to Python, i.e. that you do run into problems in general when you want to express overloaded methods in Python. But as @mp5gosu pointed out, my major point was that the function does not accept named arguments at all. Which is mainly a problem because the docs tell you explicitly otherwise in two ways. First of all the docs say explicitly that all arguments are optional which implies for Python usually that I can pick and choose in which arguments I can pass by passing named arguments. And secondly, you print out the signature as Vector.__init__(x=0.0, y=0.0, z=0.0) which implies the same. I would have probably ignored all this and booked it under "that's for me to know and for you to find out", if it wasn't for the fact that the method does not raise a TypeError on attempts of feeding it with such unknown named arguments. Which can make this quite critical IMHO. Cheers, zipit
  • CAMorphNode.SetPointCount() always return false

    Cinema 4D SDK python r21
    5
    0 Votes
    5 Posts
    730 Views
    J
    @m_adam Thank you for your answer. C++ documentation have a "Example" show how to use flags in CAMorph.SetMode, but python documentation not (at least in R21.022), i compared the C++ code with Python, then went back to the C++ documentation and found this.
  • The asymmetric matrix inversion issue

    General Talk python
    6
    1
    1 Votes
    6 Posts
    1k Views
    ferdinandF
    Hi, @Cairyn said in The asymmetric matrix inversion issue: I guess it depends on the point you want to make... I would mostly agree, but my point point was more the other way around. Not that shearing is a thing you commonly want to do, but the fact the you should be aware that c4d.Matrix will not enforce an orthogonal basis. Because if you thought it does, you could for example think that my_frame = c4d.Matrix(v3=my_normal) would be a sufficient way to construct an orthogonal frame where my_normal is k and then carry out some transforms with it and wonder what the heck is going wrong. @Cairyn said in The asymmetric matrix inversion issue: This has, in fact, been a point I thought long and hard about... What I meant with that passage was the story which has been attributed to many famous programmers who left a complicated piece of code only commented with "and here comes the tricky part". Usually told as a testament to both their technical genius and their communicative shortcomings. The often (at least silently) admired notion is that "everything is self explanatory for a smart person". Which of course is neither true nor very "cool". I feel you are drifting a bit into that direction. About the linear algebra stuff. In my opinion there is no wrong or right there, you can do a good job with a very coarse and with a very fine model. Although I think often the geometrical meaning of linear algebra has been neglected in teachings about it. Especially Cinema's "matrices" (which in my book do not really qualify as matrices) can be very well explained as linear maps which will automatically will make all four principal transforms intuitively clear. Everything that is left then is to explain that matrices are just another way to write a linear map, i.e. a linear combination of vectors representing a coordinate system. Cheers, zipit
  • 0 Votes
    5 Posts
    555 Views
    B
    RE: This is a limitation you also have with the visual selector Not really. You can multiple select hotspots and/or controllers in the visual selector. Anyhow, thanks for the response. I guess there is no way around this.
  • Matrices / Rotations / Quaternions when transferring data.

    General Talk
    4
    0 Votes
    4 Posts
    838 Views
    lasselauchL
    Hey guys, just wanted to let you know, that I've cracked the case in the meantime. Here are my findings: def convert_matrix_left_to_right(m): # http://www.techart3d.com/2016/02/convert-left-handed-to-right-handed-coordinates/ # m = op.GetMg() new_m = c4d.Matrix( m.off, m.v1*-1, m.v2, m.v3) return new_m def rotate_y_axis_180(): # Construct your own matrix based on rotation of axis # https://www.mathworks.com/help/phased/ref/roty.html x = c4d.Vector(-1, 0, 0) y = c4d.Vector(0, 1, 0) z = c4d.Vector(0, 0, -1) off = c4d.Vector(0, 0, 0) return c4d.Matrix(off, x, y, z) def GetGlobalRotation(obj): m = obj.GetMg() new_m = rotate_y_axis_180() * convert_matrix_left_to_right(m) return c4d.utils.MatrixToHPB(new_m, order=c4d.ROTATIONORDER_XYZGLOBAL) Indeed you have to convert from a left-handed (c4d) (hpb) to a right-handed (houdini) (xyz) coordinate system... plus I've found that you need to add 180° to the y axis, so I constructed a matrix in rotate_y_axis_180 that I can multiply to my converted matrix. Hope it helps someone... Thank you guys for your input! Have a great weekend and stay safe! Cheers, Lasse
  • 0 Votes
    4 Posts
    809 Views
    ManuelM
    hi, I had a look but as @zipit said, there's not way in python. Cheers, Manuel
  • Flat UV Projection in Python

    Cinema 4D SDK python
    3
    0 Votes
    3 Posts
    836 Views
    ?
    Thank you very much @zipit ! That works great.
  • 0 Votes
    3 Posts
    668 Views
    delizadeD
    thank you for your help.
  • Matrix and Vector access

    Cinema 4D SDK r23 python
    7
    0 Votes
    7 Posts
    1k Views
    ferdinandF
    Hey @datamilch, Thank you for reaching out to us. In general we prefer if users open new threads for their questions. You are of course welcome to link to an existing topic and say that your question relates to that. The reason for that is that even when the question of another user is right on-topic as it is here the case with your question (which in the most other cases will not be true), it still tends to derail a thread. I have not forked your question since you are on-topic. About your Question I think this thread can be a bit opaque for beginners as @Cairyn and @m_adam have approached this topic on a very technical level. The important thing to understand, is that both BaseObject.GetMg() and the fields of a c4d.Matrix, i.e., off, v1, v2, and v3 return a copy of the requested object, not an instance. In plain terms this means that the matrix/vector one retrieves is not the one used by the object/matrix but a copy of it. So, we can totally do this: >>> mg Matrix(v1: (1, 0, 0); v2: (0, 1, 0); v3: (0, 0, 1); off: (0, 0, 0)) >>> mg.off.x = 5 but it does not do what we think it would do, we changed the x-value of the returned copy, not the off vector used by the mg instance. >>> mg.off.x 0.0 >>> mg Matrix(v1: (1, 0, 0); v2: (0, 1, 0); v3: (0, 0, 1); off: (0, 0, 0)) But we can certainly set the x-component of the global offset of an object in one line. import c4d cube: c4d.BaseObject = c4d.BaseObject(c4d.Ocube) # ONE: Using parameter access # We set the the x component of the global position and the global rotation using parameter access. # There are also parameters for the relative, aka local, transform values, as well as special things # like a frozen transform. There are also functions on BaseObject which do the same thing but at # least I never use them. # See: https://developers.maxon.net/docs/py/2024_3_0/classic_resource/base_list/obase.html cube[c4d.ID_BASEOBJECT_GLOBAL_POSITION,c4d.VECTOR_X] = 9.9 cube[c4d.ID_BASEOBJECT_GLOBAL_ROTATION] = c4d.Vector(0, 0, c4d.utils.DegToRad(45)) # TWO: Use matrix and vector constructors # In three steps ... mg: c4d.Matrix = cube.GetMg() mg.off = c4d.Vector(9.9, mg.off.y, mg.off.z) cube.SetMg(mg) # ... or in two steps, although this is a bit stupid. mg: c4d.Matrix = cube.GetMg() cube.SetMg(c4d.Matrix(c4d.Vector(9.9, mg.off.y, mg.off.z), mg.v1, mg.v2, mg.v3)) # THREE: Using transforms # This is not exactly the same as the two other cases, but it is the most common operation. Here we # do not set the global x-position of #cube to 9.9, but we move it 9.9 units in the x-direction. # In code we often operate on objects with the identity transform/matrix, i.e., which "sit at origin # with the standard size and orientation". In that case transforms act the same as if we would just # set these values. The other case is that you have an object at (1, 2, 3) and then move it (3, 2, 1) # units, transforms also work for this. For the case where the object is at (1, 2, 3) and you want # to _set_ it to (9.9, 2, 3) a transform won't work unless you do the math. # Freshly instantiated objects have the identity transform, we can just pile transforms on top of # that to "set" the values. sphere: c4d.BaseObject = c4d.BaseObject(c4d.Osphere) # Just move it 9.9 units in the x-direction. sphere.SetMg(sphere.GetMg() * c4d.utils.MatrixMove(c4d.Vector(9.9, 0, 0))) # Or first move it 9.9 units in the x-direction and then rotate it 45 degrees around the z-axis. This # would also "pile" onto the previous transform we have already applied. Note that matrix # multiplication is also not commutative, i.e., first moving something and then rotating it (might) # yield something different than first rotating and then moving. sphere.SetMg(sphere.GetMg() * c4d.utils.MatrixMove(c4d.Vector(9.9, 0, 0)) * c4d.utils.MatrixRotZ(c4d.utils.DegToRad(45))) Cheers, Ferdinand