• 0 Votes
    7 Posts
    1k Views
    ManuelM
    @ivodow said in Thinking Particles allocation failure in new document: So, would ExecutePasses() with the BUILDFLAGS_EXPORT flag set be typically called just before exporting to alembic (to be on the safe side)? the exporter is calling ExecutePasses several times, you don't really need it. And because the scene can be sometimes quiet complexe, you have to call it several times in a row. for example, in the alembic exporter : [image: 1597218183449-68d39647-ef56-430b-ae1a-2189e1b83617-image.png] Cheers, Manuel
  • Centering an icon in a BITMAPBUTTON

    Cinema 4D SDK python
    3
    2
    0 Votes
    3 Posts
    637 Views
    ?
    @m_magalhaes Thank you for clarifying the Bitmap Button, Manuel.
  • Python, tool attributes and hotkeys

    Cinema 4D SDK s22 python sdk
    8
    0 Votes
    8 Posts
    2k Views
    John_DoJ
    @m_magalhaes Yes please, and sorry for the delay :3
  • Adding Undos for CommandData Changes

    Cinema 4D SDK python
    7
    0 Votes
    7 Posts
    717 Views
    ?
    @m_magalhaes That's helpful, thank you, Manuel!
  • 0 Votes
    4 Posts
    713 Views
    ManuelM
    hi, you could also use LoadDocument lowPoly = c4d.documents.LoadDocument("preset://Optimized_Assets.lib4d/Asset_Library.c4d", c4d.SCENEFILTER_OBJECTS | c4d.SCENEFILTER_MATERIALS) As the documentation says: Similar to LoadFile() but this time the document is not put into the editors list of documents and it gives control over the loaded document. Cheers, Manuel
  • 0 Votes
    5 Posts
    540 Views
    bacaB
    Thamks @zipit, it works. Just noticed it has to be adjusted with GetClone(), otherwise I'm getting "link is not alive" error def get_field_layers(op): """ Returns all field layers that are referenced in a field list. """ def flatten_tree(node): """ Listifies a GeListNode tree. """ res = [] while node: res.append(node.GetClone()) for child in node.GetChildren(): res += flatten_tree(child) node = node.GetNext() return res # get the GeListHead for the FieldList root = op.GetLayersRoot() if root is None: return [] # Get the first node under the GeListHead first = root.GetFirst() if first is None: return []
  • Changing parameters broken in S22

    Cinema 4D SDK
    5
    0 Votes
    5 Posts
    918 Views
    M
    @m_adam Thanks for clarifying!
  • Prevent Projects from opening if dragged.

    Cinema 4D SDK python sdk
    5
    0 Votes
    5 Posts
    878 Views
    lasselauchL
    @mp5gosu Whooop! Thanks, Robert! You have to return a tuple so return (c4d.NOTOK, False) does the trick for me. Thank you!!! Cheers, Lasse
  • Add and Remove Edge Loops Poly Object

    Cinema 4D SDK python r19
    12
    1
    0 Votes
    12 Posts
    3k Views
    A
    Hi @r_gigante, Not to worry! I understand! Thanks for your help! Andre
  • GLB extract textures

    General Talk
    7
    0 Votes
    7 Posts
    4k Views
    J
    @Macsmiller I apologize for the late reply. Here is the plugin. glTF Importer plugin I managed to finish it and integrate it into Cinema 4D. You can follow the updates here: glTF Importer topic Maybe I am asking a question in the wrong topic - where can I find some sample code that can be used to create various import settings and write them to default presets.lib4d?
  • Some attempts at nondestructive modeling

    Moved General Talk r21 python
    5
    1
    0 Votes
    5 Posts
    1k Views
    X
    Hi: After a trial run, the script was tested successfully. By setting the name suffix of Python Tag, the problem of repeated running of Tag can be solved. Taking c4d.DIRTYFLAGS_SELECT as an example, if the point, line, and surface selections change, it will execute, otherwise it won't. The Python script code is as follows: import c4d #e-mail: [email protected] def main(): Name = op.GetName() Objects = op.GetObject() Changed = Objects.GetDirty(c4d.DIRTYFLAGS_SELECT) Text = ["xit" + str(Changed)[-1]] if str(Name).count(Text[0][:-1]) != 0 : if str(Name).find(Text[0][:-1]) != str(Name).rfind(Text[0][:-1]) : if str(Name)[str(Name).rfind(Text[0][:-1]):] == Text[0] : if str(Name).find(Text[0][:-1]) <= 0: #Do not execute, exit the program. print ("Does not perform.") op.SetName(str(Text[0])) return else: #Do not execute, exit the program. op.SetName(str(Name)[:str(Name).find(Text[0][:-1])] + str(Text[0])) print ("Does not perform.") return else: if str(Name).find(Text[0][:-1]) <= 0: op.SetName(str(Text[0])) print ("Perform.") else: op.SetName(str(Name)[:str(Name).find(Text[0][:-1])] + str(Text[0])) print ("Perform.") else: if str(Name)[str(Name).rfind(Text[0][:-1]):] == Text[0] : #Do not execute, exit the program. print ("Does not perform.") return else: op.SetName(str(Name)[:str(Name).find(Text[0][:-1])] + str(Text[0])) print ("Perform.") else: print ("Perform.") op.SetName(str(Name) + str(Text[0])) print ("pass") #The next thing to execute.
  • Alembic Export Options Not Working

    Cinema 4D SDK python s22
    7
    0 Votes
    7 Posts
    2k Views
    BigRoyB
    Just want to confirm here that I'm facing this same issue - only setting the negative state first and then the positive state after seems to make this work. So, thanks for the workaround. Here's the reported bug on our pipeline: https://github.com/ynput/ayon-cinema4d/issues/6 And this is what fixed it: https://github.com/ynput/ayon-cinema4d/pull/8 Looking at 'what' fixes it this most definitely sounds like a bug. (I tested in Cinema4D 2023.2.2 on Windows 10)
  • Custom mouse icon, define touch point.

    Cinema 4D SDK
    4
    0 Votes
    4 Posts
    707 Views
    RenatoTR
    Anyway, i'll add my custom offset to the mouse coordinate to match the point from the center, as seem by default.
  • 0 Votes
    5 Posts
    1k Views
    E
    ok, my apologies. i guess my question is at what point to i check for dirty, and at what point do i insert the nulls?
  • 0 Votes
    6 Posts
    1k Views
    ferdinandF
    Hi, I am sorry, I hate it myself when people talk in acronyms, assuming everyone knows what they are referring to. PNG stands for Pseudo-random Number Generator. Here is an example for a simple trigonometric pseudo random hash function. Cheers, zipit """A simple example for a very simple "one-at-a-time" Pseudo-random Number Generator (PNG). It is basically just one line of code, which you can find on line 32. """ import c4d import math def hash_11(x, seed=1234, magic=(1234.4567, 98765.4321)): """Returns a pseudo random floating point hash for a floating point number. The hash will lie int the interval [-1, 1] and the function is a very simple generator that exploits the periodicity of the trigonometric functions. A more sophisticated approach would be to exploit avalanche behavior in bit-shift operations on binary data, like the Jenkins Rotation does for example. The postfix in the name (_11) is a common way to denote the inputs and outputs for PNGs. 11 means that it will take one (real) number and return one (real) number. 13 means that it takes one and returns three, i.e. returns an (euclidean) vector. Args: x (float): The value to hash into a pseudo random number. seed (int, optional): The seed value. This could also be a float. magic (tuple, optional): The magic numbers. The second one should be bigger then the first and both should be real numbers. Returns: float: The pseudo random hash for x in the interval [-1, 1]. """ return math.modf(math.sin(x + seed + magic[0]) * magic[1])[0] def hash_13(x, seed=1234, magic=(1234.4567, 98765.4321)): """Returns a pseudo random vector hash for a floating point number. Wraps around hash_11. Returns: c4d.Vector: The pseudo random hash for x in the interval [-1, 1]. """ vx = hash_11(x, seed, magic) vy = hash_11(x + vx, seed, magic) vz = hash_11(x + vy, seed, magic) return c4d.Vector(vx, vy, vz) def main(): """Entry point. """ # Some very crude statistics for the hashes. samples = int(1E6) # Generate 1E6 of each numbers = {i: hash_11(i) for i in range(samples)} vectors = {i: hash_13(i) for i in range(samples)} # Compute their arithmetic mean. amean_numbers = sum(numbers.values()) * (1./samples) amean_vectors = sum(vectors.values()) * (1./samples) # Report the results. print "First three random numbers: ", numbers.values()[:3] print "First three random vectors: ", vectors.values()[:3] msg = "Arithmetic mean of all random numbers (should converge to zero): " print msg, amean_numbers msg = "Arithmetic mean of all random vectors (should converge to zero): " print msg, amean_vectors if __name__ == "__main__": main() First three random numbers: [-0.8036933662078809, 0.20401213006516628, 0.6249060598929645] First three random vectors: [Vector(-0.804, -0.022, -0.872), Vector(0.204, 0.541, 0.115), Vector(0.625, 0.782, 0.896)] Arithmetic mean of all random numbers (should converge to zero): -0.000127638074863 Arithmetic mean of all random vectors (should converge to zero): Vector(0, 0, 0)
  • 0 Votes
    6 Posts
    1k Views
    ?
    I have been looking at my plugins and my biggest question so far is how to handle urllib2 in a way that will work with both Python 2.7 and 3.7.7. Everything else just seems to be adding parentheses to print functions. I found this Cheat Sheet: Writing Python 2-3 compatible code that suggests: # Python 2 and 3: easiest option from future.standard_library import install_aliases install_aliases() from urllib.parse import urlparse, urlencode from urllib.request import urlopen, Request from urllib.error import HTTPError However, trying that in Cinema 4D threw this error: ImportError: No module named future.standard_library Fortunately, there are some alternatives to try, like # Python 2 and 3: alternative 4 try: from urllib.parse import urlparse, urlencode from urllib.request import urlopen, Request from urllib.error import HTTPError except ImportError: from urlparse import urlparse from urllib import urlencode from urllib2 import urlopen, Request, HTTPError From that article: "urllib is the hardest module to use from Python 2/3 compatible code."
  • Mute Object Animation

    Cinema 4D SDK r21 python
    5
    0 Votes
    5 Posts
    453 Views
    B
    @zipit Gotcha. Thanks for the reminder
  • Max value of an EditNumberArrows in TagData

    Cinema 4D SDK s22 python
    3
    0 Votes
    3 Posts
    356 Views
    ?
    @m_adam Thanks, Maxime!
  • Best coding practices

    Cinema 4D SDK python
    3
    0 Votes
    3 Posts
    611 Views
    mfersaouiM
    @zipit Thank you much.
  • Mirroring with Matching or Different Axes

    Cinema 4D SDK s22 python
    26
    0 Votes
    26 Posts
    17k Views
    kbarK
    @zipit I also want to say that the amount of time you contribute here to help out developers is very generous of you. You are doing an amazing job. I would hope that Maxon would actually pay you some retainer fee for your time or at least provide you with a free subscription for all the help you have given everyone here.