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

use OBJECT_MODIFIER to affect op with deformer

 Post Reply Post Reply
Author
Message
merkvilson View Drop Down
Member
Member
Avatar

Joined: 2017 Feb 27
Online Status: Offline
Posts: 65
Post Options Post Options   Quote merkvilson Quote  Post ReplyReply Direct Link To This Post Topic: use OBJECT_MODIFIER to affect op with deformer
    Posted: 2018 Jan 12 at 7:00am
is it possible to use OBJECT_MODIFIER to affect op with another deformer?


    def ModifyObject(self, mod, doc, op, op_mg, mod_mg, lod, flags, thread):

        reduction = c4d.BaseObject(c4d.Obend) #Bend Deforemer
        reduction[c4d.DEFORMOBJECT_STRENGTH] = c4d.utils.Rad(90) #Strenght = 90 degrees
        reduction.InsertUnder(op) #Insert bend under op
        
op.Message(c4d.MSG_UPDATE)
return True

This code display deformer but it has no effect on the geometry.


Edited by merkvilson - 2018 Jan 12 at 7:06am
Follow: www.twitter.com/Merkvilson
Back to Top
merkvilson View Drop Down
Member
Member
Avatar

Joined: 2017 Feb 27
Online Status: Offline
Posts: 65
Post Options Post Options   Quote merkvilson Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Jan 12 at 7:01am
I registered this plugin as a MODIFIER

info = c4d.OBJECT_MODIFIER 

Do I have to include other flags, in order to make it work with other deformers?


Follow: www.twitter.com/Merkvilson
Back to Top
merkvilson View Drop Down
Member
Member
Avatar

Joined: 2017 Feb 27
Online Status: Offline
Posts: 65
Post Options Post Options   Quote merkvilson Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Jan 12 at 7:36am
Seems like it's working but not in the viewport. 
What could cause such behavior?
Follow: www.twitter.com/Merkvilson
Back to Top
merkvilson View Drop Down
Member
Member
Avatar

Joined: 2017 Feb 27
Online Status: Offline
Posts: 65
Post Options Post Options   Quote merkvilson Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Jan 12 at 2:11pm
Well... I used CSTO command but now I see 2 objects in my viewport. in the rendered image, this base object is hidden and only modified geometry is displayed.


Follow: www.twitter.com/Merkvilson
Back to Top
merkvilson View Drop Down
Member
Member
Avatar

Joined: 2017 Feb 27
Online Status: Offline
Posts: 65
Post Options Post Options   Quote merkvilson Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Jan 13 at 3:30pm
 Where can I find more information about OBJECT_MODIFIER plugins? :)
Follow: www.twitter.com/Merkvilson
Back to Top
merkvilson View Drop Down
Member
Member
Avatar

Joined: 2017 Feb 27
Online Status: Offline
Posts: 65
Post Options Post Options   Quote merkvilson Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Jan 15 at 5:44am
Is it possible to show only modified object and hide the original one?
Follow: www.twitter.com/Merkvilson
Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1608
Post Options Post Options   Quote Andreas Block Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Jan 15 at 5:47am
Hi,

the issue is actually not so much OBJECT_MODIFIER related.
You are not allowed to modify the scene from within the scene evaluation pipeline. This includes ObjectData's GetVirtualObjects(), ModifyObjects(), GetContour() and Execute() functions, also similar functions from other NodeData derived plugin types.

Actually a modifier usually modifies the geometry directly, using existing deformers is at least a bit unusual, see example Py-SpherifyModifier.

But if you really have to use existing deformers to get the job done, you can still do so, even if it may be not the fastest route to go. In this case you'd clone the object, you want to modify, insert it into a temporary document, add the modifier there, execute the temporary document and then transfer the result to the object being modified in ModifyObject().

Maybe you can let us know a bit more about your final intention, then we could discuss here, what's the best way to get there.

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

Joined: 2017 Feb 27
Online Status: Offline
Posts: 65
Post Options Post Options   Quote merkvilson Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Jan 15 at 5:58am
Originally posted by Andreas Block

Maybe you can let us know a bit more about your final intention, then we could discuss here, what's the best way to get there.

I want to perform several modeling operations on the desired object but before this, I would like to use poly reduction, in order to simplify its geometry and then execute modeling commands. :)
Follow: www.twitter.com/Merkvilson
Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1608
Post Options Post Options   Quote Andreas Block Quote  Post ReplyReply Direct Link To This Post Posted: Today at 5:50am
Hi,

since R19 we have a PolyReduction class. Here's some more information in the PolygonReduction manual.
Not only will this be way easier to implement, than the above described deformer approach, but it should also perform way better.

Cheers,
Andreas
SDK Support Engineer
Back to Top
 Post Reply Post Reply

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.109 seconds.