Maxon Developers
    • Downloads
      • All Downloads
      • Cinema 4D Python SDK
      • Cinema 4D C++ SDK
      • Cineware SDK
      • ZBrush GoZ SDK
      • Cinema 4D Python Examples
      • Cinema 4D C++ Examples
      • Project Tool
      • SDK Database
    • Documentation
      • Cinema 4D Python SDK
      • Cinema 4D C++ SDK
      • Cineware SDK
      • ZBrush GoZ SDK
    • Forum
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Forums
      • Overview
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • News & Information
      • Downloads
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Register
    • Login
    1. Home
    2. Tags
    3. python
    Log in to post
    • All categories
    • mfersaouiM

      External dependencies question

      Cinema 4D SDK
      • python • • mfersaoui
      3
      0
      Votes
      3
      Posts
      173
      Views

      M

      Hi @mfersaoui there is nothing wrong with the way you are doing, but I would like to point out that the sys.path is a global variable shared over the current python environment. Meaning that 3rd party will be able also to import your own module so it's recommended to have an ambiguous name (e.g. if your module1.py is called util.py) people will be able to do import util and this can be really misleading so it's preferred to have a unique name (maybe you can start with a prefix).

      Finally, the solution offered by @mp5gosu is the cleanest one as it will create a local import space, so your util.py will only be importable by your own pyp file that actually calls the local import so it's so far the cleanest way as you are not "polluting" the global sys.path.

      But which one is the best, only you can decide according to what you are aiming to produce.
      Cheers,
      Maxime.

    • ?

      Grabbing a GeUserArea when using InputEvent

      Cinema 4D SDK
      • r23 python windows • • A Former User
      4
      0
      Votes
      4
      Posts
      151
      Views

      ferdinandF

      Hi @blastframe,

      yes, that would be one, and probably the more modern way to do it. I personally like also an explicit call to the base implementation. I think it is more readable for someone else reading your code. But that is probably a rather subjective choice. So for clarity, I am speaking about something like this:

      foo = bar * baz return c4d.gui.GeUserArea.InputEvent(self, msg)

      There is of course the advantage of super taking care of calling the proper implementation(s) for you which is not taken care of by this approach, but you cannot have everything and in this case things are rather unambiguous for us here 😉

      Cheers,
      Ferdinand

    • R

      Run plugin every frame

      Cinema 4D SDK
      • • • RneCGI
      3
      0
      Votes
      3
      Posts
      222
      Views

      R

      After a few mails with Ferdinand I switched to a Tag plugin solution. This does the job perfectly.
      So the solution was not to use an Object data solution but a TagData.

      Thanx!

    • beatgramB

      Undo Problem For TagData Plugin

      Cinema 4D SDK
      • python r23 • • beatgram
      4
      0
      Votes
      4
      Posts
      162
      Views

      ManuelM

      hi,

      @beatgram said in Undo Problem For TagData Plugin:

      So these bracket notation style is safer than using BaseContainer in any case?

      this should be exactly the same.
      Sorry i didn't got time to warp my head around it.

      Cheers,
      Manuel

    • ?

      Erratic Keyboard Messages in GeDialog

      Cinema 4D SDK
      • python r23 windows • • A Former User
      7
      0
      Votes
      7
      Posts
      221
      Views

      ?

      @mp5gosu Sorry, I missed it! That works! In case other devs have a solution, I'll mark yours as the right answer. Thank you!

    • ?

      Animating the Status Spin with Render Progress

      Cinema 4D SDK
      • python windows r23 • • A Former User
      3
      0
      Votes
      3
      Posts
      173
      Views

      ?

      @ferdinand Thank you, Ferdinand for the thorough answer and ideas for workarounds. I don't quite have my head around how to use threading in Cinema 4D yet but you've inspired me to look into it. Thank you!

    • rsodreR

      UVW coordinates in ShaderData.Output()

      Cinema 4D SDK
      • r23 c++ python • • rsodre
      12
      0
      Votes
      12
      Posts
      415
      Views

      ManuelM

      hi,

      I don't see how we could do it with the Draw Method in a efficient way.

      Cheers,
      Manuel

    • H

      Dialog Plugin with Progress Bar or SetStatusBar

      Cinema 4D SDK
      • python • • HerrMay
      12
      0
      Votes
      12
      Posts
      536
      Views

      ferdinandF

      Hello @HerrMay,

      thank you for your reply. Please note that we prefer users to flag topics as solved, as doing it ourselves always comes with the danger of erroneously flagging a posting as solved. Please refer to our Forum Guidelines - Forum Feature: Ask as Question in case you do not know how to do this.

      Cheers,
      Ferdinand

    • ?

      CUSTOMGUI_FONTCHOOSER Text Disappears

      Cinema 4D SDK
      • python windows r23 • • A Former User
      5
      0
      Votes
      5
      Posts
      148
      Views

      ferdinandF

      Hi @blastframe,

      so this is a bug that happens independently of Python. It also not connected to your example using a dangling dialog, but to the fact that it is using a dialog. When you implement some form of NodeData plugin and a FONT resource element in it, this bug won't happen.

      I have opened a bug report for this. For now you would have to either use my little workaround or move outside of a GeDialog environment an implement the whole plugin as some form of NodeData plugin. If a dialog is of high priority for you, you could also display an instance of that node in a DescriptionCustomGui inside your dialog. Which should work and somewhat be a mix of both options.

      Cheers,
      Ferdinand

    • ?

      Scaling a GeUserArea in a ScrollGroup

      Cinema 4D SDK
      • python windows r23 • • A Former User
      5
      0
      Votes
      5
      Posts
      229
      Views

      ferdinandF

      Hello @blastframe,

      I forgot to put the final outcome for this here. So, after some back and forth we decided to not fix this for reasons I unfortunately cannot disclose. But we will update the documentation in an upcoming release to avoid this being as opaque as it currently is. This is probably not what you hoped for, but currently the best course of actions for us.

      Thank you for your understanding,
      Ferdinand

    • M

      Crash with GeListHead and TreeViewFunctions SetName()

      Cinema 4D SDK
      • python r20 r21 r23 • • mp5gosu
      4
      0
      Votes
      4
      Posts
      234
      Views

      M

      Hi @mp5gosu , I will set the topic as closed.

      Note that the fix will not come in the next update but don't worry we have it logged and it's on our list of things to fix in the future.

      Cheers,
      Maxime.

    • dskeithD

      Polygon Islands Convenience Method?

      Cinema 4D SDK
      • r23 python • • dskeith
      6
      0
      Votes
      6
      Posts
      511
      Views

      P

      this script breaks an poly object into island, colorized it by random, offset to center of bounding box and some noise. after that i connects all islands again.

      its super fast compared to my older "solution"

      import c4d from c4d import gui import random def AddVertexColor(s,center,rad): cnt = s.GetPointCount() tag = c4d.VariableTag(c4d.Tvertexcolor, cnt) data = tag.GetDataAddressW() bs = s.GetPointS() bs.SelectAll(cnt) done = [] points = s.GetAllPoints() r = random.random() for i in range(cnt): g = (points[0]-center).GetLength() / rad b = c4d.utils.noise.Noise(points[0]*0.01,rad) c = c4d.Vector(r,g,b) c4d.VertexColorTag.SetColor(data, None, None, i, c) s.InsertTag(tag) def main(): random.seed(666) selection = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_NONE) for s in selection: center = s.GetMp() rad = s.GetRad().GetLength() c4d.CallCommand(12298) c4d.CallCommand(17891) mesh = s.GetDown() while mesh: AddVertexColor(mesh,center,rad) mesh = mesh.GetNext() c4d.CallCommand(100004768) c4d.CallCommand(16768) # Execute main() if __name__=='__main__': main()
    • ?

      SSL TLSV1_ALERT_PROTOCOL_VERSION Error on Mac

      Cinema 4D SDK
      • r19 python macos • • A Former User
      3
      0
      Votes
      3
      Posts
      496
      Views

      ?

      @m_adam Thank you, Maxime! Have a good weekend.

    • ?

      Handles in R18

      Cinema 4D SDK
      • python r19 windows • • A Former User
      3
      0
      Votes
      3
      Posts
      202
      Views

      ?

      Thank you for letting me know, @ferdinand !

    • P

      How to remove generator childs when converting via "c"

      Cinema 4D SDK
      • python r20 r21 s22 r23 • • pyr
      6
      0
      Votes
      6
      Posts
      299
      Views

      P

      forget about it. i removed the c4d.OBJECT_INPUT flag during development and forgot to add it back.

    • V

      How to know baking is end with BakeTextureTag?

      Cinema 4D SDK
      • python r19 • • velbie
      7
      0
      Votes
      7
      Posts
      323
      Views

      M

      Hi @velbie with the latest update of Cinema 4D (R24 SP1), the BAKE_TEX_AO_VERTEXMAPS issue is fixed.

      Cheers,
      Maxime.

    • S

      Querying and Storing Object Information

      Cinema 4D SDK
      • python • • Sturdy_Penguin
      9
      0
      Votes
      9
      Posts
      360
      Views

      ferdinandF

      Hi @Sturdy_Penguin ,

      without further questions or feedback, we will consider this thread as solved by Monday and flag it accordingly.

      Cheers,
      Ferdinand

    • beatgramB

      How To Add Undo For Description Added Dynamically

      Cinema 4D SDK
      • python r23 • • beatgram
      8
      0
      Votes
      8
      Posts
      250
      Views

      beatgramB

      @Cairyn Thank you so much for helping me again! 😊

    • M

      OOP class struggles: treeview envoce gui refresh outside class ListView()

      Cinema 4D SDK
      • • • mogh
      4
      0
      Votes
      4
      Posts
      387
      Views

      M

      thank you for your help, I am trying to understand ...

      am I right in the assumption that this is not "clean code" in a pythonic sense ?
      kind regards

    • X

      Gets the point weight of the Field object.

      Cinema 4D SDK
      • • • x_nerve
      2
      0
      Votes
      2
      Posts
      183
      Views

      ferdinandF

      Hi @x_nerve,

      thank you for reaching out to us. The most straightforward way to sample a FieldObject is FieldObject.Sample; there are also other sample methods attached to the various fields related classes, most notably c4d.FieldList. We have two examples in the Python SDK examples which showcase field sampling, fieldlist_sampling_r20 and fieldobject_sampling_20.

      You also mention "Is there a way to get the weight of the cube field points?"; you are probably aware of this, but since your phrasing could imply otherwise, it seems noteworthy to point out that fields are not discrete. So in other words, there is no finite amount of points you can exhaustively sample for a field object, since the object is non-discrete. You have to pick a point or a set of points you want to sample for a field object, which can be any point in in the value range c4d.Vector can handle.

      If there are any questions left, please do not hesitate to ask.

      Cheers,
      Ferdinand