• 0 Votes
    14 Posts
    1k Views
    DunhouD
    @ferdinand Thaks for all of that explains . With your detailed and friendly explains , A new habbitor like me can code within Cinema 4D as well . Thanks for that !
  • embed interface

    Cinema 4D SDK python sdk
    6
    4
    0 Votes
    6 Posts
    857 Views
    M
    @ferdinand thanks a lot, best wishes!
  • something problem with using TreeViewCustomGui

    Cinema 4D SDK python sdk
    3
    2
    0 Votes
    3 Posts
    460 Views
    M
    @ferdinand thank you very much,it had been solved According to your method,have a good day!
  • 0 Votes
    4 Posts
    672 Views
    ferdinandF
    Hello @kng_ito, I agree that it is odd, or as you nicely put it, unkind. The problem is also that the meaning of segments in the context of a SplineObject (the data count of the Tsegment tag) and a LineObject (the data count of its Tline tag) is being mixed up. B(Cache).GetSegmentCount() = 2 <- A LineObject instance. B(Cache).GetTags() = [ <c4d.VariableTag object called with ID 5712 ... <- The Tline tag. <c4d.VariableTag object called with ID 5680 ... <c4d.SegmentTag object called with ID 5672 ... <- The Tsegment tag for the host. <c4d.PointTag object called with ID 5600 ... ] The problem of this design is that LineObject.GetSegmentCount returns the segment count in the sense of its host object, the SplineObject, as the number of disjunct curve sections in the spline (segment tag). The segments in the sense of a LineObject, the number of line segments the hosting spline object has been quantized into in the LineObject (line tag), is only indirectly accessible over getting the Tline tag of that object. Which in turn might confuse users why they cannot get a specific segment as you wanted to. But this design was apparently intentional and aims at minimizing the number of tags in the traverseable scene-graph (things inside caches are out of sight so to speak and not a problem). It is therefore unlikely that we will change this. The best I can do for now, is adding a note to LineObject.GetSegmentCount and SplineObject.GetSegmentCount which hints at the problem. Cheers, Ferdinand
  • How to get Viewport pixel color

    Cinema 4D SDK s26 python
    4
    1
    0 Votes
    4 Posts
    432 Views
    chuanzhenC
    @ferdinand Hi,i use RenderDocument in python,although it is a little slow and needs to wait for a second, it works successfully. Thanks for your help,gif show it works: [image: 1660008431592-ssss.gif]
  • Filename Gui how get empty folder path

    Cinema 4D SDK python s26
    3
    1
    0 Votes
    3 Posts
    378 Views
    chuanzhenC
    @ferdinand Thanks. I create Filename Gui in CreateLayout it work,this is code: bc = c4d.BaseContainer() bc.SetBool(c4d.FILENAME_DIRECTORY,True) self.AddCustomGui(1012, c4d.CUSTOMGUI_FILENAME,"",c4d.BFH_SCALEFIT, 50, 20, bc)
  • Display points

    Cinema 4D SDK python
    2
    0 Votes
    2 Posts
    571 Views
    ferdinandF
    Hello @merkvilson, thank you for reaching out to us. It would have been helpful to indicate what you would consider older and the latest version of Cinema 4D in this context, but I assume your problem is caused by you using a pre-S22 TagData plugin which implements TagData.Draw in a S22+ version. With S22, the flag TAG_IMPLEMENTS_DRAW_FUNCTION has been added to c4d.plugins.RegisterTagPlugin. You must pass it, when you want the method to be called. I would also point out that ptList = op.GetCache().GetAllPoints() is rather risky, as is assumes op to always have a cache which is a point object. Objects can have no caches and caches can contain other things than point objects. You should be a bit more defensive here, even if you intend to only use the plugin 'in this one scenario where this will work'. Cheers, Ferdinand
  • 0 Votes
    3 Posts
    461 Views
    T
    Hi Ferdinand. Thank you for the thorough response. Apologies for the ambiguity on my part. For a test project I wanted to fetch star coordinates (for ~100K–1M+ stars) and their brightness values. Then instance Redshift spheres onto them with a material where the brightness of each point is piped into the material's emission. This was a test project to get started with python. I also wanted to see if c4d has a way of working with points and attributes. I don't think the real-world (galaxy?) data is available, but ideally each star would also have a radius, which would drive the sphere scales/sizes. I'm familiar with cloner/effector/field setups, but I was looking for a programatic approach. I don't know how to pass specific values to each point (brightness in this case) and then to clones with effectors/fields.
  • 0 Votes
    10 Posts
    1k Views
    DunhouD
    @ferdinand It seems more complicate and detailed doc in C++ document than python. I will be helpful to move on. Thanks to that
  • Look At Camera Tag and text orientation

    Cinema 4D SDK python
    12
    0 Votes
    12 Posts
    3k Views
    Z
    @ferdinand Thanks, that is exactly correct - in fact I did not need to make the orthonormal vector, all one needs do is set the objects Y-axis equal to the camera, and get the x-axis by cross product . I think I correctly handle the pathological situation after looking at the limiting cases. The modified function is below. Randy EPSILON = 1E-5 # The floating point precision we are going to assume, i.e., 0.00001 # This is based on the python Look at Camera example # https://github.com/PluginCafe/cinema4d_py_sdk_extended/tree/master/plugins/py-look_at_camera_r13 def GetLookAtTransform(host: c4d.Matrix, target: c4d.Matrix, reverseZ=True) -> c4d.Matrix: """Returns a transform which orients its z/k/v3 component from #host to #target. """ # Get the position of both transforms. p: c4d.Vector = host.off q: c4d.Vector = target.off # The normalized offset vector between 'host' (object to be reoriented) and 'target' (the camera) # will become the z-axis of the modified frame for the object . # # If reverseZ = True, the new z-axis is points from camera toward object, if False the reverse # I turn reverseZ on by default, as my initial application is to text splines, which are meant to be # viewed looking down the object z-axis. # In the original implementation # (https://github.com/PluginCafe/cinema4d_py_sdk_extended/tree/master/plugins/py-look_at_camera_r13 ) # the modified y-axisis computed using the global y-axis, and this does not consistently # keep the text upright in the view of the camera. Instead, simply take the object y-axis same as camera y. # # In the pathological case of new object z-axis parallel to camera y : # If reverseZ : set object z = camera y , object y = -camera Z # else : set object z = -camera y, object y = -camera z # if reverseZ : z: c4d.Vector = ~(p - q) if 1. - abs(z * target.v2) > EPSILON : y = target.v2 else : z = target.v2 y = -target.v3 else : z: c4d.Vector = ~(q - p) if 1. - abs(z * target.v2) > EPSILON : y = target.v2 else : z = -target.v2 y = -target.v3 # get x using cross product x: c4d.Vector = ~(y % z) # Return the frame (x, y, z) plus the offset of #host as the look-at transform. return c4d.Matrix(off=p, v1=x, v2=y, v3=z)
  • How to detect a new light and pram change?

    Cinema 4D SDK s26 sdk python windows
    6
    0 Votes
    6 Posts
    2k Views
    DunhouD
    @bentraje Thanks a lot ! I always want to spend some thing to do this , but unfortunately I am struggling to work with rendering . If I have some time hopes I can change this a bit more
  • Set IRR settings

    General Talk
    3
    0 Votes
    3 Posts
    767 Views
    I
    Works like a charm, thank you!
  • SetTime() and document updating

    Cinema 4D SDK python r21
    12
    0 Votes
    12 Posts
    2k Views
    ManuelM
    @brucek5 said in SetTime() and document updating: It sounds like 'op' is similar to 'this' in c# op is a pre-defined variable. Using a tag to script your python, op point to the tag itself. But using the visual selector, op will point to the object in the link and could be None. You can have a look at our manuals page where you will find Python Scripting Nodes that will give information about pre-defined variables for each node where you can use python. Cheers, Manuel
  • Gimbal Lock Safe Target Expression

    Cinema 4D SDK python
    7
    0 Votes
    7 Posts
    2k Views
    ferdinandF
    Hello @indexofrefraction, Is this correct / covers all cases to get the targets position in local space? There is no "correct" way. The way I showed you is a/the common approach to construct a frame from a vector. A vector in R³ (opposed to a tuple of rotation values which might be stored in a type called Vector) only defines two out of the three degrees of freedom of a rotation in R³. When you construct a frame manually, you can define that third degree of freedom with the up vector (or just right away construct the frame out of two meaningful vectors which are already orthogonal to each other). VectorToHPB() makes this decision for you, as it, quote, '[will always set] the bank [...] to 0.0' because a vector does not store three angles but two. I personally would never go over the Euler angles, as this seems unnecessarily complicated, but this is a question of personal preference and not right or wrong. Is this correct / covers all cases to get the targets position in local space? (~(op.GetUpMg() * op.GetFrozenMln())) * target.GetMg().off [- op->GetRelPos();] What @s_bach did there was specific to that example which operates on Euler angles. I cannot explain all the math here, but in general, the position of an object B relative to an object A, i.e, the local offset of B within the coordinate system of A is just the delta of both offsets transformed by the coordinate system of A. A: c4d.BaseObject B: c4d.BaseObject mgA: c4d.Matrix = A.GetMg() mgB: c4d.Matrix = B.GetMg() # This is the location of B in relation to A in world coordinates. delta: c4d.Vector = mgB.off - mgA.off # The same point but in the coordinate system of A. If B were parented to A, it would have # this offset. offBLocalToA: c4d.Vector = mgA * delta I again would have personally done some things differently in the loot-at example, but the solution is just as good as others. what is m = utils.MatrixMove(op.GetAbsPos()) * utils.HPBToMatrix(op.GetAbsRot()) * utils.MatrixScale(op.GetAbsScale()) in this context? (ps. GetAbsScale misses the brackets in the docs) Please read the docs, I cannot explain here transforms from scratch again. Thanks for the hint for the missing parenthesis, I will fix that in an upcoming release. As a tip: Do not fixate too much on frozen transforms in our API, you can ignore them more or less, the relevant methods are GetMg and GetMl. and... is this the real code of the Target Tag ? I am not quite sure how you mean that? You mean if the LookAtCamera::Execute example is identical to what the ::Execute of Ttargetexpression does internally? No really, the expression ~(op.GetUpMg() * op.GetFrozenMln()) pops up there, but Ttargetexpression also constructs the frame manually with the cross product, but there are more steps involved than in my simple example. But again, there is no real right or wrong here, you can do things differently if you want to. And before the question comes up, no, we unfortunately cannot share the code of the target expression. I would also point out again our Forum Rules, especially regarding the scope of support and the rules of conduct. We cannot teach you the math and you must implement your things yourself. Cheers, Ferdinand PS: If you want to explore what the frozen transform means (it is mostly smoke and mirrors for the API perspective, unless you want to specifically deconstruct a transform), I would recommend adding a Python tag to objects, adding this code, and then play around with the freeze transform feature. import c4d op: c4d.BaseTag def main() -> None: """ """ def PrettyMatrixString(m: c4d.Matrix): """_summary_ """ s: str = f"{m.__class__.__name__}(" l: int = len(s) for i, v in enumerate((m.off, m.v1, m.v2, m.v3)): s += f"{' ' * (l if i != 0 else 0)}({round(v.x, 3):>8}, {round(v.y, 3):>8}, {round(v.z, 3):>8}\n" return s[:-1] + ")" node: c4d.BaseObject = op.GetMain() if not isinstance(node, c4d.BaseObject): # Should technically never happen return for line in ( f"GetMg():\n{PrettyMatrixString(node.GetMg())}", f"GetMl():\n{PrettyMatrixString(node.GetMl())}", f"GetFrozenMln():\n{PrettyMatrixString(node.GetFrozenMln())}"): print (line) [image: 1657105682679-09c7c8b7-63d3-4020-8ef3-2881ff262003-image-resized.png]
  • 0 Votes
    15 Posts
    2k Views
    M
    Hi with the Release 2023.1 the bug with maxon.AssetInterface.GetAssetUrl have been resolved. Cheers, Maxime.
  • 0 Votes
    3 Posts
    441 Views
    K
    Hi @ferdinand, I deleted my original post because I realized the question contained my misunderstanding. And now your answer has completely solved the problem I had. Thank you very much for your detailed response!
  • Osubdivisionsurface ?

    Cinema 4D SDK python
    4
    0 Votes
    4 Posts
    764 Views
    ferdinandF
    Hey @indexofrefraction, Well, that is because Mograph is one of the areas where the type symbols have not been exposed. So, to be clear: There is no cloner object symbol. But now that you brought this up again, I just realized that we (the SDK Team) never talked about fixing this and I do not see (fully) why. I have a suspicion why this might have been postponed or refuted in the past, but I will bring it up again. In the end we just must add a few defines to ge_prepass.h and then users do not have to jump through these hoops anymore. It will be difficult to catch all the missing symbols, but we could at least start with the ones we know. I will update the thread with the outcome of our discussion. Edit: So, we talked about this, and came to the obvious conclusion, that we should do what we should have done a long time ago, and fix this. I cannot give an ETA, but I will try to give it priority as I think this is a problem which impacts many users. Cheers, Ferdinand
  • 0 Votes
    2 Posts
    404 Views
    ferdinandF
    Hello @未凡fh, Thank you for reaching out to us. Support on this forum is only being provided in the English language, as this serves our community best, and because we also simply do not speak all languages of the world. I think the language you posted in is Simplified Chinese, please excuse me when I wrong, but that is what Google said. No-one on the SDK Team speaks that language. And even if we would, we would refuse to answer in this language as it would lock out large parts of the community. As we do for requests which come in German, French, or Spanish (languages we do speak). Running your request through Google Translate, I got this: Let me ask: How do I detect an object moving and send a message when an object moves? Please confirm that this is your request and that we can communicate in English. Thank you for your understanding, Ferdinand
  • 0 Votes
    3 Posts
    786 Views
    ferdinandF
    Hello @conductor, Thank you for reaching out to us. I am glad that you could solve your problem yourself. Please do not hesitate to ask further questions you might have. Cheers, Ferdinand
  • SaveWorldPreferences() in Python

    Cinema 4D SDK
    5
    0 Votes
    5 Posts
    882 Views
    a_blockA
    Hi Ferdinand, thanks a lot! No ETA needed, I'm grateful it will be added eventually. Cheers, Andreas