• 0 Votes
    4 Posts
    772 Views
    ferdinandF
    Hello @HerrMay, Is the multiplication of a matrix with a vector (mg.off = mg * p) essentially the same what mg * c4d.utils.MatrixMove(vec) does? No, mg * p multiplies a matrix by a vector which will yield the transformed vector p'. mg * c4d.utils.MatrixMove(vec) on the other hand multiplies two matrices, yielding the combined transform of them, a new matrix. What would be equivalent to mg * p is mg * c4d.utils.MatrixMove(p) * c4d.Vetcor(0, 0, 0). Please note that the whole subject is also out of scope of support as declared in the forum guidelines. I understand that the subject is a common barrier for the more on the artist-sided leaning users of ours, and I help where I can, but we cannot teach you vector math, linear algebra, or however you want to label this subject. Find below a short code example. Cheers, Ferdinand Output: M = Matrix(v1: (1, 0, 0); v2: (0, 1, 0); v3: (0, 0, 1); off: (0, 100, 0)) p = Vector(100, 0, 0) M * p = Vector(100, 100, 0) M * c4d.utils.MatrixMove(c4d.Vector(100, 0, 0)) = Matrix(v1: (1, 0, 0); v2: (0, 1, 0); v3: (0, 0, 1); off: (100, 100, 0)) M * c4d.Vector(100, 0, 0) = Vector(100, 100, 0) N * c4d.Vector( 0, 0, 0) = Vector(100, 100, 0) M * c4d.utils.MatrixMove(p) * c4d.Vector(0, 0, 0) = Vector(100, 100, 0) Code: import c4d # Let us assume #M to be the global matrix/transform of some object #op. View it as a tool to # transform a point in global space into the local coordinate system of #op. M: c4d.Matrix = c4d.Matrix(off=c4d.Vector(0, 100, 0)) # The matrix #M now has this form: # # | v1 1 0 0 | # The "x-axis" of the coordinate system defined by #M. # | v2 0 1 0 | # The "y-axis" of the coordinate system defined by #M. # | v3 0 0 1 | # The "z-axis" of the coordinate system defined by #M. # ---------------------- # | off 0 100 0 | # The origin of the coordinate system defined by #M. # # I.e., #M has the standard orientation and scale and only translates all things by 100 units # on the y-axis. So, the object #op would have the Euler angles (0°, 0°, 0°), the scale (1, 1, 1) # and the position (0, 100, 0) in world coordinates. # Define a vector #p to transform and print both #M and #p. p: c4d.Vector = c4d.Vector(100, 0, 0) print(f"{M = }") print(f"{p = }") # Transforming a point #p by a matrix #M will yield a point #q that is in the same relation to #M # as #p is to the global frame. q: c4d.Vector = M * p # #q will be the vector (100, 100, 0) because , (100, 100, 0) and #M are the same relation as #p # and the identity matrix are, a.k.a., the world frame. In a less technical way, (0, 100, 0) is the # origin of the coordinate system defined by #M. And to express #p in a manner as if #M would be # its coordinate system, we have to add (0, 100, 0), because that is the new origin. For orientation # and scale it works more or less the same, I would recommend having a look at the Matrix manual or # Wikipedia article on the subject. print (f"{M * p = }") # We can construct new transforms in many ways (again, Matrix Manual :)), one of them is by # combining multiple transforms via matrix multiplication. # We "add" the translation transform (100, 0, 0) to #M. Note that matrix multiplication is not # commutative, i.e., "M * N = N * M" does not always hold true. In this case it would because only # translations are involved. N: c4d.Matrix = M * c4d.utils.MatrixMove(c4d.Vector(100, 0, 0)) print(f"{M * c4d.utils.MatrixMove(c4d.Vector(100, 0, 0)) = }") # To get the same point as #q when multiplying a point #r with #N, we must pick the null-vector # because the origin of #N is already at where M * (100, 0, 0) is. print (f"{M * c4d.Vector(100, 0, 0) = }") print (f"{N * c4d.Vector( 0, 0, 0) = }") # We can also do it in one operation: print (f"{M * c4d.utils.MatrixMove(p) * c4d.Vector(0, 0, 0) = }")
  • 0 Votes
    4 Posts
    668 Views
    M
    Hello @HerrMay, without further questions or postings, we will consider this topic as solved by Monday 05/06/2023 and flag it accordingly. Thank you for your understanding, Maxime.
  • 0 Votes
    3 Posts
    428 Views
    H
    Hi @m_adam, alrighty, good to know that this will be looked into and eventually get fixed. Yes, I remember I returned True in the past. In the python tag as well as in the TagData equivalent. As returning super didn't work. Thanks for the information anyway. Cheers, Sebastian
  • 0 Votes
    3 Posts
    716 Views
    B
    Hi Manuel, Thank you very much. Your script works perfectly in my environment. Only one modification I made was if "color" in portPath: to if "color" in str(portPath): Thank you.
  • Python Tag how to hide a mogragh object

    Cinema 4D SDK python windows 2023
    7
    0 Votes
    7 Posts
    1k Views
    DunhouD
    @Manuel Oh, what a pitty! I know that I can dot it with a effector, but it is not a "all in one" solution for my convenient,but that's it , I will not spend times in it. Thanks for your research, and @HerrMay thanks for your enthusiastic answers ! Cheers~ DunHou
  • Crash when apply a Tag plugin.

    Cinema 4D SDK 2023 python windows
    7
    0 Votes
    7 Posts
    1k Views
    DunhouD
    Hey @ferdinand ,Thanks for your detailed explains forever. Now it is clear to read the res files , and you show me the Agent Ransack last year, I use this software for learn something , and the C++ document is also good for the res file, but some of the data is distribute anywhere , like BITMAPMUTTON , I remember that I search for no fading option for a long time, but in python document it has a user friendly position in sdk. Maybe a document improvement or more Github examples are both welcomed( seems lots of works ) Thanks for your patience! Cheers~ DunHou
  • 0 Votes
    3 Posts
    653 Views
    H
    Hi @m_adam, thanks for the explanation and your example code. That will absolutely suffice my needs. Good to know though that additional information may be available in the future. Cheers, Sebastian
  • Object Generator as Particles

    Cinema 4D SDK python
    2
    0 Votes
    2 Posts
    400 Views
    ManuelM
    Hi, sorry, the display of this tab is hardcoded an only available for a couple of builtin objects. What you can do is have a Matrix object in object mode that point to your generator, the rs tag being applied to the matrix object. You can also create that setup inside your generator. Below, i am using a cube but that could be your PointObject instead. Keep in mind that python is slow, using it for point cloud or anything related to particles might be super slow. from typing import Optional import c4d doc: c4d.documents.BaseDocument # The document evaluating this python generator op: c4d.BaseObject # The python generator hh: Optional["PyCapsule"] # A HierarchyHelp object, only defined when main is executed def main() -> c4d.BaseObject: . cube = c4d.BaseObject(c4d.Ocube) parent = c4d.BaseObject(c4d.Onull) cube.InsertUnder(parent) matrix = c4d.BaseObject(c4d.Omgmatrix) matrix.InsertUnder(parent) matrix[c4d.ID_MG_MOTIONGENERATOR_MODE] = c4d.ID_MG_MOTIONGENERATOR_MODE_OBJECT matrix[c4d.MG_OBJECT_LINK] = cube matrix[c4d.MG_POLY_MODE_] = c4d.MG_POLY_MODE_VERTEX rsTag = matrix.MakeTag(1036222) rsTag[c4d.REDSHIFT_OBJECT_PARTICLE_MODE] = 2 return parent Cheers, Manuel
  • 0 Votes
    3 Posts
    1k Views
    H
    Hello @ferdinand, alright I see. I already thought that you would teach me once again that the naive thought I put up here would'nt hold up to the real world. Thanks for the explanation and the example you provided. I guess that will do just fine. As always much appreciated! Cheers, Sebastian
  • Export fbx of only selected objects

    Cinema 4D SDK python
    9
    0 Votes
    9 Posts
    1k Views
    J
    Hello @Aleksey, without further questions or postings, we will consider this topic as solved by Friday, the 11th of august 2023 and flag it accordingly. Thank you for your understanding, Maxon SDK Group
  • Checking for ALT GetInputState() issue

    Cinema 4D SDK python 2023
    6
    1
    0 Votes
    6 Posts
    1k Views
    P
    Great, thank you Glad I can help to improve this great program.
  • 0 Votes
    3 Posts
    780 Views
    G
    Entschuldigung. Vielen Dank.
  • Place multiple objects on spline and align

    Cinema 4D SDK python 2023
    5
    1
    0 Votes
    5 Posts
    2k Views
    P
    And once again, thank you!
  • Quicktab SDK Example

    Cinema 4D SDK r20 2023 python sdk
    9
    1
    0 Votes
    9 Posts
    2k Views
    M
    While rethinking about it last night, it may not be that slow if on user interaction you just flush the main group and re-attach already existing dialog. So you need to modify your `def _DrawQuickTabGroup(self)`` method like so to only display visible dialog: def _DrawQuickTabGroup(self, onlyVisible=True): """ Creates and draws all the SubDialog for each tab, take care it does not hide these according to a selection state. Returns: True if success otherwise False. """ # Checks if the quicktab is defined if self._quickTab is None: return False activeIds, activeNames = self.GetActiveTabs() # Flush the content of the group that holds all ours SubDialogs self.LayoutFlushGroup(ID_MAINGROUP) #self.GroupBorderSpace(left=5, top=5, right=5, bottom=5) # Iterates over the number of tab to create and attach the correct SubDialog for tabId, (tabName, tabGui) in enumerate(self._tabList.items()): toDisplay = tabId in activeIds if not toDisplay: continue self.AddSubDialog(ID_QUICKTAB_BASE_GROUP + tabId, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 0, 0) self.AttachSubDialog(tabGui, ID_QUICKTAB_BASE_GROUP + tabId) self.LayoutChanged(ID_MAINGROUP) return True Then in the Command message instead of calling DisplayCorrectGroup you should call _DrawQuickTabGroup like so: def Command(self, id, msg): if id == ID_QUICKTAB_BAR and self._quickTab: self._DrawQuickTabGroup() return True Regarding your question and classic Tab, find an example in Remove a GeDialog Tab Group but as you can see this is also not possible to remove a tab without redrawing everything . Cheers, Maxime.
  • 0 Votes
    3 Posts
    863 Views
    Y
    Oh my gosh, so comprehensive answer! I'm so impressed that you put so much effort in it. You a great, thank you a lot!
  • 0 Votes
    1 Posts
    395 Views
    No one has replied
  • 0 Votes
    4 Posts
    699 Views
    ferdinandF
    Hello @HerrMay, Funny enough DrawPoints seems to internally use the "same points" to draw, one gets to see when one edits the points of a polygon object. In S26 the points are round (thats probably why I was thinking of circles) while in R20 they are squares. No question here, just an observation. As you can see, in the script I retrieve the cache of the object we are going to draw. # Get the cache of the object representing the plugin in the object manager, i.e., more or # less what we returned in GetContour, Cinema 4D has however exhausted the cache for us, and # the cache is not a SplineObject but a LineObject (i.e, the cache of a SplineObject). cache: c4d.LineObject = op.GetDeformCache() or op.GetCache() if not isinstance(cache, c4d.LineObject): return c4d.DRAWRESULT_O This not only enables us to deal with splines affected by a deformer correctly, but also and more importantly with spline generators as for example the Circle spline generator. Such generators do not have any control points one could retrieve, their cache will always contain LineObject instances and not SplineObject instances (when they have been implemented correctly). This is also what I was referring to in my comment, because OffsetYSpline returns a SplineObject as its cache in GetContour, but Cinema 4D will 'exhaust' that cache for us by returning the cache of the cache, the LineObject. A LineObject represents a SplineObject over its current interpolation settings. What is actually weird though is that the color gradient you used here to color the points doesn't work in R20. The points are simply drawn black there. Possibly a Python 2/3 issue caused by integer/float division differences? Yes, this is Python 3 code. In Python 2 integers divide by default as integers. Simply wrap one of the numbers into a float, e.g., f: float = float(i)/float(count). Allow one follow up question. How can I draw only the control points of the spline? In your example you use a circle primitive which has - when made editable - exactly four points making up the shape via tangents. Where as the drawn points using the intermediate points of the circle as well. You can use BaseObject.GetRealSpline to get the underlying editable spline object for a spline. So, when you would replace the section quoted above with this: cache: c4d.SplineObject = op.GetRealSpline() if not isinstance(cache, c4d.SplineObject): return c4d.DRAWRESULT_OK You would now draw the control points of the SplineObject representing the spline generator rather than the vertices of its underlying LineObject. The problem in this case is that the plugin you have chosen is calling 'Current State to Object' (CSTO) on the input object which it is cloning and returning offset-ed (see line 130 in your code listing). CSTO is of course just replacing an object with its cache state. So, when you put a circle spline below the offset spline, it will still be drawn as in the LineObject cache version because the cache and the BaseObject.GetRealSpline representation are in this case identical. Cheers, Ferdinand
  • GeDialog Timer Always Printing to Console?

    Cinema 4D SDK s26 2023 python
    2
    2
    0 Votes
    2 Posts
    318 Views
    K
    Well, that was a fast solution... couldn't it have emerged BEFORE I hit submit?!? Haha, the solution was easy... I was returning True on the Timer function. Took a look at the python memory viewer example and noticed they don't return a value on it. Removed the return from my Timer() function and all is working as expected. def Timer(self, msg): print("Timer") That's it:)
  • How to get the status of video post in python

    Cinema 4D SDK sdk python
    4
    1
    0 Votes
    4 Posts
    751 Views
    R
    @ferdinand Thank you, the code runs well. └(^o^)┘
  • Fieldlist HasContent() GetCount() bug workaround

    Cinema 4D SDK python r23
    3
    0 Votes
    3 Posts
    667 Views
    M
    Hello @mikeudin, without further questions or postings, we will consider this topic as solved by Monday 05/06/2023 and flag it accordingly. Thank you for your understanding, Maxime.