Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login
    1. Maxon Developers Forum
    2. SolarPH
    3. Posts
    S
    • Profile
    • Following 0
    • Followers 0
    • Topics 8
    • Posts 21
    • Best 1
    • Controversial 0
    • Groups 0

    Posts made by SolarPH

    • Is it possible to update the Python Version a release uses?

      Hello!

      Just wondering if there was any way to update the python version Cinema4D uses on its scripts, or is there any way to switch versions of python per script from the python version included in Cinema4D to the version that had been installed on the machine (for example, Python 3.9.2)

      posted in Cinema 4D SDK
      S
      SolarPH
    • RE: PYTHON - Getting CTsound volume strength on current frame

      That does its thing, but like the Sound Effector included in MoGraph Effectors, even if I set the offset of the track like ahead like 30 frames, it still reads volume/sample data from the position of the track with high volume on its original position if the track started in 0F

      For like...

      If my voice starts at 40F and I pick an offset of 30F, it should start reading sample data from 70F and not 40F

      By this code, it behaves the same as the Sound Effector, but the data is readable and can be applied to any object.

      posted in Cinema 4D SDK
      S
      SolarPH
    • PYTHON - Getting CTsound volume strength on current frame

      Hello! I was trying to create my own variation of the Sound Effector on R19 since the one on my version doesn't fit the purpose of LipSyncing since it doesn't follow Sound Track time offset from the timeline,

      I tried several python functions including CTrack.GetValue() but it always return 0

      Any way possible that I can get the sound strength value from a sound track (CTsound type) using python? I can make the thing using Sound Node, but once played, it cannot be stopped or controlled by timeline itself.

      posted in Cinema 4D SDK python
      S
      SolarPH
    • RE: urllib2.urlopen fails on C4D for Mac

      I had a question too partially related to this one.

      I was using urllib2 to access a payhip product page of my own, so that when I use my VersionReader Node in XPresso, it can access the current preset version code present on my product page. For some reason, when I try to open the webpage, it ends up not working. It has no feedback reply as well. I had it on a try-except block so I don't knoe what is the exact error (yet)

      However, I can access my github webpage for the build code, so having a solution for this is not really needed for my side (my friend does not have a github page so we kinda need to have a workaround)

      I was using R19 for this set of scripts.

      posted in Cinema 4D SDK
      S
      SolarPH
    • RE: Sound Effector Object Mismatch / Missing / Not Working Fields (R14 (to R18 probably) and R19 comparison)

      Actually nevermind. I found a workaround for this

      However...
      1404bc9a-f7fd-45ab-94d2-18567afa163d-image.png
      If we base on the sound effector, and the waveform on the timeline, the offset does not work apparently, or am I missing something?

      posted in Cinema 4D SDK
      S
      SolarPH
    • Sound Effector Object Mismatch / Missing / Not Working Fields (R14 (to R18 probably) and R19 comparison)

      Hello!

      I was trying to create a LipSync Engine built using Python and the Sound Effectors included in the MoGraph package.

      For some reason, I saw some mismatch in Sound Effector Build between R14, the one made in R18, and the one in R19.

      This is the screenshot of the Effector Tab in the versions I got (R14, R18, and R19)
      18147c07-5b6f-4d08-a9d7-5305cebcbe7d-image.png

      posted in Cinema 4D SDK
      S
      SolarPH
    • R19 randomly deletes preset data

      Hello!

      I used R19 today and made some changes to my preset folder which contains several objects which builds a whole character in a DIY manner, meaning it contains parts of character.

      For some odd reason, R19 randomly deletes the objects from it when I perform a certain process on the said preset which gets its data deleted. The deletion percentage is random as I have inspected during different istances of it happening. It does not happen everytime, more like 50/50 of it to happen.

      Process of Reproducing the bug:
      Unlock the preset that has Read Only via C4D
      Take out an object
      Modify the object
      Delete the original object from Preset and replace it with modified one
      Make the same preset as Read Only
      Exit Cinema4D

      Before I exit Cinema4D, I check if all objects I need to be on the preset was on there, so I don't know what is happening on my rig. There was no crash on Cinema4D so crashing is will not be a reason on why it doesn't have half of the contents.

      posted in Cinema 4D SDK
      S
      SolarPH
    • RE: Python - InExcludeData initialization problem

      @zipit Thanks for sharing the code. Now I know that initializing the InExcludeData is not InExcludeData.__init__ and the correct way was c4d.InExcludeData(), which I really did not think of when initializing specialized data containers.

      posted in General Talk
      S
      SolarPH
    • Python - InExcludeData initialization problem

      I had a problem (again) with InExcludeData. this time with initializing the thing

      Also, it seems like there is no way to merge two different InExcludeData fields to make a single InExcludeData list with no object duplicates on it.

      Can any of you can explain to me how can I really do this using Python?
      8333ccd7-1f71-49e9-aa85-e7296b4a2eee-image.png
      It basically was unclear for me as of now...

      posted in General Talk
      S
      SolarPH
    • Exclude Objects from Environment

      Is it possible for objects to be excluded from the environment's effect? For example, if the Fog option is enabled, the fog won't affect several objects that are meant to be not affected.

      I have 2 planes with custom sun and moon textures which is really annoying right now because it always gets affected by the fog, and also I don't want to cover the sky with fog either, so I need to exclude them from the fog effect of the Environment object...

      I hope there was a solution for this problem...

      posted in Cinema 4D SDK
      S
      SolarPH
    • RE: Python NODES - Shouldn't really they can change the scene?

      @zipit said in Python NODES - Shouldn't really they can change the scene?:

      This statement is a bit nit-picky, but this is not really a relative path, but a url with a unusual scheme (the Maxon preset scheme that is). You can get the preset folders with c4d.storage.GeGetC4DPath() and the respective path symbols and then check with these and os.path.exists.

      Thanks for mentioning that, and also telling the correct usage. I've beem havong a bad rime using os.path.relpath() and os.path.abspath() with os.path.exists()

      Edit: One thing though, this code kinda has it's own holes, because I encountered a problem once more. I think what os.path.exists() looks up is the OS Absolute Path, which in this case, not very helpful because of two points:

      1: The preset:// followed by file name do not follow the OS path of the file, like preset://thispreset.lib4d was the path, but preset://browser/thispreset.lib4d is the one which it was looking for.

      1. The preset name on C4D do not follow the actual filename, for example, I have ThisRig by Someone.lib4d for OS path, and c4d reads it on the program as ThisRig v# - someone and have the path preset://ThisRig v# - someone.lib4d insted of the one being looked up by os.path.exists

      Results on a test run using your code:
      preset://browser/default.lib4d prints out the full OS path

      preset://testrig.lib4d prints False

      preset://broswer/testrig.lib4d prints out the full OS path if file name was testrig.lib4d

      preset://broswer/testrig.lib4d prints False if file name was testrig0.lib4d

      So far, I want to detect if this path exists on Cinema4D preset list, even if it doesn't exist in any of the directories being used by Cinema4D itself, as long as it's listed in the Preset list. This was due to the nature of some users just drags and drops a .lib4d file from some folder.

      However, I think using a combination of detecting if a Bitmap is valid by looking at the file resolution if it matches, since it also brings the correct and always updated preset:// path (Update Textures are still a need since this isn't automatic when either Preset Folder name was changed, or it was moved to a new preset. I just thought of other ways to do that other than the Bitmap way.

      posted in Cinema 4D SDK
      S
      SolarPH
    • RE: Python NODES - Shouldn't really they can change the scene?

      I got these results, later on, I encountered the said crash:

      v1 (Python Node Direct) = Secured Code, Draw Delay, No Crash
      v2 (Python Node Code Transfer to Python Tag) = Secured Code, Function Delay, Draw Delay, No Crash
      v3 (Python Generator) = Exposed Code, No Delay, No Crash
      v3.1 (Python Node Code Transfer to Python Generator) = Secured Code, Crashes before Draw

      posted in Cinema 4D SDK
      S
      SolarPH
    • RE: Python NODES - Shouldn't really they can change the scene?

      @PluginStudent said in Python NODES - Shouldn't really they can change the scene?:

      @SolarPH said in Python NODES - Shouldn't really they can change the scene?:

      without any need of any plugin

      If you want to have interaction with a scene without plugins you could do this:

      • Add a Python Scripting Tag to your scene
      • Add user-data buttons and other UI to that tag
      • implement the message() function of that tag
      • in that message() function, you can react to interaction with the tag's user-data UI
      • you can write code that is executed from the main thread to edit the scene safely
      • and leave the poor Python Node and all that thread stuff alone...

      I checked with the c4d.threading.GeIsMainThread() on Python Scripting Tag and Python Generator. Seems both runs on Main Thread. I can use them, but...

      Using those ways have no way to lock the code using a password, which I always do with my code to protect them against unwanted changes.

      Is there any way to seal the code until it executes all?

      Also, is there a way to look if a relative directory exists like "preset://mylib.lib4d/" without the other stuff inside it? That's what I need right now to do verification on the files before my python node passes the code to python generator or python scripting tag before they execute anything, just to still secure the code.

      Edit: LoadFile() and ShowInFinder() doesn't work as I expected. I hope there was a specific one that works from R14 to the latest one (just for the sake of people who still use 32-bit)

      EDIT(2):

      After testing Python Scripting Tag with the same code but transfered using the Python Node protected inside XGroup, it has a delay until you deselect the owner, then it executes the code, but it doesn't run on the main thread as printed by c4d.threading.GeIsMainThread()

      Test in a Python Generator also not want to run on Main Thread during merge...

      also I can't get what message() was used

      posted in Cinema 4D SDK
      S
      SolarPH
    • RE: Python NODES - Shouldn't really they can change the scene?

      Also, Anyone know how to extract Thread Name? Or if possible, a list of Thread ID with their thread name would be useful.

      I have put a piece of code on my node and this was what it prints out:
      d023389b-d320-4a41-9478-b0696f5fa158-image.png

      Also, I wonder if procesisng the threads can have a delay using a timer thing...

      posted in Cinema 4D SDK
      S
      SolarPH
    • RE: Python NODES - Shouldn't really they can change the scene?

      @m_adam @zipit @PluginStudent
      Can you check the file I have on this folder (google drive)
      https://drive.google.com/open?id=1IZ76o55libdd8d_DUtljETEt7v6FU6MY
      The time of the rig files being available are only limited, since this rig is sold for purchase for animators.

      Upon observation, there was no delays about the objects being imported having any delay before it shows up on my Viewport, and I also noticed that in both versions (R14 and R19), obj.Remove() adds an Undo event, and I can retrieve back the Rig Importer without deleting the imported character.

      On R19 observation though, it seems like c4d.EventAdd() doesn't force all updates to show up on viewport, as if it cannot update the viewport from execution source being a Tag. Since the object is a one-time use, and cannot be keyframed, it doesn't pose too much problem on the scene.

      Other than that, nothing much. Just looking up for your recommendations about making a behavior like this python node, and how to make it really on the Main Thread without any need of any plugin (because I actually need this to be compatible with all versions from R14 to R21+ without updating any plugins).

      posted in Cinema 4D SDK
      S
      SolarPH
    • RE: Python NODES - Shouldn't really they can change the scene?

      @zipit said in Python NODES - Shouldn't really they can change the scene?:

      @SolarPH said in Python NODES - Shouldn't really they can change the scene?:

      Is there any way for the execution to be placed from a python node to anywhere it's safer to run into?

      Hi,

      I have admittedly not red the whole thread here, but one approach to modifying the scene graph from a non-main-thread context could be registering a plugin id and using that id as a message id.

      From your threaded context (i.e. your Xpresso Python node) you can send the id as a core message. In a separately implemented MessageData plugin you then listen for that message and upon reception set a flag in the instance of your MessageData plugin that you want to do something.

      When you are sure, that you are back in the main thread in your ```MessageData`` plugin (you might have to use a timer message for that), you can execute whatever the message told you to execute.

      Cheers,
      zipit

      Is there any way to not make it dependent on a plugin? My actual main goal is to modify the scene (not in the level of me calling any GUI around c4d). It seems to be successful and I was just about to post the scene with the specific importer and the specific preset which my importer was made for. You can look at it later. For now, it was being tested on R19 from R14

      posted in Cinema 4D SDK
      S
      SolarPH
    • RE: Python NODES - Shouldn't really they can change the scene?

      @m_adam said in Python NODES - Shouldn't really they can change the scene?:

      Passing None in the MergeDocument will not make it run into the main thread, you just pass the thread you are currently in, and it will be this thread that will be tested if you should leave or not, but it does not modify where the code is executed. So calling MergeDocument is not fine because, in the end, you modify the current document especially if there are some materials. And this could make Cinema 4D Crash since a lot of stuff happens during a merge.

      Is there any way for the execution to be placed from a python node to anywhere it's safer to run into?

      So far, there's no issues about crash or lag during a merge (the merge happens on scene to preset folder method)

      Also, I will send the sample files which I work into on the Rig Importer and see what can be done for making sure it was to run safer (ofcourse not letting it crash Cinema4D during merge)

      posted in Cinema 4D SDK
      S
      SolarPH
    • RE: Python NODES - Shouldn't really they can change the scene?

      @m_adam said in Python Tags - Shouldn't really they can change the scene?:

      Hi @SolarPH when you say -- Import Rig Parts > Arrange Parts > Modify UserData > Delete Importer --
      it looks like these steps can come from a series of buttons pressed.

      It can be, but I planned it to be all automated using a series of codes.

      If you are doing all of that in the Execute method, then it's not ok and it could affect the c4d stability (we do have crash reports about that).

      I've set all of those outside Execute method to ensure that it wouldn't loop infinitely. I often connect it to an if/else statement (connected to a boolean/integer switch that switches itself off after the first cycle) to ensure that it wouldn't make Cinema4D crash.

      make sure to call StopAllThread, but you can even call EventAdd

      I actually haven't tested StopAllThread line yet, but I can already use EventAdd() after any commands that changes the scene in terms of heirarchy and inserted objects. I haven't really tested doing a delete command, but I have some ways to let the code know what to delete after the cycle. Utilizng ports as a way to actually pass the correct object data on the code makes it easier for me to execute this kinds of codes on my python tags.

      if you are in the main thread you are safe to do whatever you want

      Also, According to the online manual about python codes for cinema4d (official documentation), for example, I do

      c4d.documents.MergeDocument(doc,Path,c4d.SCENEFILTER_OBJECTS|c4d.SCENEFILTER_MATERIALS,None)
      

      will make it run on Main C4D Thread (i don't actually know if not putting the None at the end of the code makes it run on another thread, but when I tried, it doesn't actually crash C4D since the line only runs once because of the nature of the switch I used)

      @PluginStudent said in Python Tags - Shouldn't really they can change the scene?:

      The purpose of a Python Tag is to define the behavior of existing objects in the scene, similar to an XPRESSO tag. The Python Tag is part of the scene execution pipeline, and you must not edit scene from withing the scene execution.

      If you want to edit the scene (insert stuff etc.) you must do this solely from the main thread.

      ALSO I just noticed... I meant Python Node, not Python Tag. lemme correct that one....

      posted in Cinema 4D SDK
      S
      SolarPH
    • RE: Update button

      Seems like it executes very well, but only delayed because you are changing a combobox/dropdown instead of the slider value itself. Try modifying the sliders instead of the combobox/dropdown for less delays

      EDIT: I forgot that those sliders might be also just Numerical IDs so it may be inaccurate as well in terms of it being able to handle the data being fed on, and may change depending on the constraint build-up

      I guess you can't do anything than to deal with the delay. Try making the time slider running while you switch that button back and forth if it updates everytime something changes on the scene. Usually it's just a 1-frame delay, or whenever something is updated. In alternative, try to use c4d.EventAdd() after each if-else statement

      posted in Cinema 4D SDK
      S
      SolarPH