Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > PYTHON Development
  New Posts New Posts
  FAQ FAQ  Forum Search

Sample Node With Python

Author
Message
  Topic Search Topic Search
kjya2008 View Drop Down
Member
Member


Joined: 2017 Jan 23
Online Status: Offline
Posts: 23
Direct Link To This Post Topic: Sample Node With Python
    Posted: 2017 Mar 19 at 8:11pm
Hi,all.

  In Xpresso,there is a node called "smple node",is ti possible to create it with python tag?for example,how to use the falloff of a plain effector to control a lot of  cubes' filter(as the screenshot below). I have achieved it via Xpresso setup,but I want to do it via python tag,How to do achieve this?somebody has an example code? any help would be very appreciated!



I want to achieve this goal via python tag ,is it possible? I tried this code below,but not work,maybe it is the cause that I don't know how to use the FalloffDataData.

import c4d
from c4d.modules.mograph import FalloffDataData

def main():

    null = op.GetObject()
    cubes = null.GetChildren()
    FalloffDataData = doc.SearchObject('plain')

    for cube in cubes():
        mg = cube.GetMg()
       
        FalloffDataData.mat = mg
       
        if  FalloffDataData.strength >= 0:
            cube[c4d.PRIM_CUBE_DOFILLET] = 1
           
        else:
            cube[c4d.PRIM_CUBE_DOFILLET] = 0



Best Wishes!
John.


Edited by kjya2008 - 2017 Mar 20 at 11:15pm
Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1878
Direct Link To This Post Posted: 2017 Mar 20 at 5:59am
Hi,

can you perhaps describe the scenario in more detail? The cubes you want to filter are just cubes or are they created by a cloner (maybe even MoGraph Cloner)? Perhaps the Python Effector is much more, what you are looking for?

Cheers,
Andreas
SDK Support Engineer
Back to Top
kjya2008 View Drop Down
Member
Member


Joined: 2017 Jan 23
Online Status: Offline
Posts: 23
Direct Link To This Post Posted: 2017 Mar 20 at 10:40pm
Hi,Andreas.

I am sorry!I have re-edited my post . my question is that how I can achieve the effect in the screenshot via python tag or python effector .Thank you!


Bset wishes!



Edited by kjya2008 - 2017 Mar 20 at 10:41pm
Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1878
Direct Link To This Post Posted: 2017 Mar 22 at 10:09am
Hi,

I'm afraid I have no good news on this topic.

There's currently no way to achieve this in Python.

The point is, the effector only gets "executed", if it's part of a MoGraph generator (cloner,...). So the Python Effector code (or also the Plain Effector) won't get run at all in the scenario shown in your screenshot. The Sample node in Xpresso uses special internal messages to force execution of the Effector and to sample the falloff in order to get the desired result. These messages (and there data types) are not available in Python. Sorry.

Cheers,
Andreas
SDK Support Engineer
Back to Top
kjya2008 View Drop Down
Member
Member


Joined: 2017 Jan 23
Online Status: Offline
Posts: 23
Direct Link To This Post Posted: 2017 Mar 22 at 10:41pm
Hi,Andreas.
Thank you all the same! I'll keep it mind. I have another question that how to use the "FalloffDataData" function,for example, FalloffDataData.mat function, or this class function is only used in plugingdata? I am confused about this class,would you help me understanding this function?thank you !
Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1878
Direct Link To This Post Posted: 2017 Mar 24 at 9:35am
The C++ docs contain a bit more info on FalloffDataData. It's needed, when writing custom FalloffData plugins.

Cheers,
Andreas
SDK Support Engineer
Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1878
Direct Link To This Post Posted: 2017 Mar 27 at 9:45am
Ooopsy, sorry, I need to correct myself a bit or at least add some information.

While it's not possible to sample the falloff of an effector in Python in the above described scenario, in C++ there's at least the C4D_Falloff class. This can be used to add falloffs to for example a deformer or generator. With this you can set up your own falloff and sample it to your liking.

Of course neither in Python (yet) nor exactly what was asked for. But on the other hand, it's at least an option to sample a falloff.



Edited by Andreas Block - 2017 Mar 27 at 9:45am
Cheers,
Andreas
SDK Support Engineer
Back to Top
Donovan Keith View Drop Down
Member
Member


Joined: 2002 Oct 30
Location: United States
Online Status: Offline
Posts: 199
Direct Link To This Post Posted: 2017 Jun 28 at 1:28pm
Just wanted to put in a request to be able to Sample an arbitrary falloff. Specifically, I'm looking to sample the falloff data of an effector linked via userdata.
Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1878
Direct Link To This Post Posted: 2017 Jun 29 at 9:57am
Hi Donovan,

though I can't make any promises, chances aren't that bad, that this will be possible in one of the future releases.

Cheers,
Andreas
SDK Support Engineer
Back to Top

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.61 [Free Express Edition]
Copyright ©2001-2009 Web Wiz

This page was generated in 0.095 seconds.