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

    GetContour() issues

    SDK Help
    0
    20
    2.3k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 02/03/2011 at 02:46, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   11.x 
      Platform:   Windows  ;   
      Language(s) :     C++  ;

      ---------
      It seems like it's come up a number of times, yet there's no real solution found for it...

      My plugin is a generator object that outputs a spline object, but it gets information from other objects. That means I have to use GetVirtualObjects() to get it to update. But unless I use GetContour(), a lot of objects and tags won't recognize its spline. (Hair module, Align to Spline Tag, Spline Node, several NURBS objects... they won't read it.)

      The thing is, Mograph's Tracer Object seems to be a spline object, changes dynamically, and is readable as if GetContour is called every frame.

      Did they do something to the GetVirtualObjects() or GetContour() calls to make it work, or did they do a custom solution for it?

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 02/03/2011 at 03:34, xxxxxxxx wrote:

        How does your plugin object communicate with other objects, through parent-child relation or through link fields, lists etc?

        cheers,
        Matthias

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 02/03/2011 at 03:39, xxxxxxxx wrote:

          Mine uses a couple of In/Exclude link boxes to read the input objects.
          As for the RegisterObjectPlugin method, I have OBJECT_GENERATOR|OBJECT_ISSPLINE for the info.

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 03/03/2011 at 01:58, xxxxxxxx wrote:

            Uhh... follow-up question...

            Is there a way to manually invoke the GetContour method from another function in the same plugin? I tried calling GetContour from within GetVirtualObjects, but it didn't look like it updated at all.

            Right now the only workaround I found was to have a dummy description on my object and add animation keyframes to it. It calls GetContour every frame during animation, but during viewport editing it doesn't, and there are things like Particles that I can read inside GetVirtualObjects but not in GetContour...

            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 03/03/2011 at 02:22, xxxxxxxx wrote:

              I am not sure myself. I will forward the problem to our developers.

              cheers,
              Matthias

              1 Reply Last reply Reply Quote 0
              • H
                Helper
                last edited by

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 03/03/2011 at 02:25, xxxxxxxx wrote:

                Thanks Matthias,

                I'll do some experiments on my side. Hopefully I can find a decent workaround.

                Cheers,
                -gene

                1 Reply Last reply Reply Quote 0
                • H
                  Helper
                  last edited by

                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                  On 28/06/2011 at 08:03, xxxxxxxx wrote:

                  I'm also having a hard time with this. I use a link field to link to a mesh, on which i base my spline. My spline only updates when i change some value in the attribute editor.

                  i'm using python, r12.

                  1 Reply Last reply Reply Quote 0
                  • H
                    Helper
                    last edited by

                    THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                    On 01/07/2011 at 05:24, xxxxxxxx wrote:

                    i've sort of worked it out in a tag instead. if you create spline, add the tag to it, then link to a mesh in the tag, the tag will modify the spline so it goes through all the vertices of the mesh. gives exactly the same result as the tracer with deforms and sweepnurbs.
                    one problem is that the spline disapears in the viewport sometimes.

                    Osfspaghetti.res:
                    #############################################

                    CONTAINER Osfspaghetti
                    {
                    NAME Osfspaghetti;
                    INCLUDE Obase;

                    GROUP ID_OBJECTPROPERTIES
                    {
                    	LINK PYMESHLINK_MESH { ACCEPT {Opolygon;} }
                    }
                    

                    }
                    #############################################

                    Osfspaghetti.h:
                    #############################################
                    #ifndef _Osfspaghetti_H_
                    #define _Osfspaghetti_H_

                    enum
                    {
                    PYMESHLINK_MESH = 10000
                    };

                    #endif
                    #############################################

                    Osfspaghetti.str:
                    #############################################
                    STRINGTABLE Osfspaghetti
                    {
                    Osfspaghetti "Spaghetti";

                    PYMESHLINK_MESH	"Object";
                    

                    }
                    #############################################

                    SF-spaghetti.pyp
                    #############################################
                    import c4d
                    import math
                    import sys
                    import os
                    from c4d import plugins, utils, bitmaps

                    PLUGIN_ID = 1000001

                    class spaghettiData(plugins.TagData) :
                        
                        def Execute(self, tag, doc, op, bt, priority, flags) :
                            
                            if op.GetTypeName() != "Spline":
                                return c4d.EXECUTIONRESULT_OK
                            else:
                                bc = tag.GetDataInstance()    
                                mesh = bc.GetLink(c4d.PYMESHLINK_MESH)
                                if not mesh:

                    return c4d.EXECUTIONRESULT_OK
                                
                                pCount = mesh.GetPointCount()
                                
                                if mesh.GetDeformCache() is None:
                                    points = mesh.GetAllPoints()
                                else:    
                                    points = mesh.GetDeformCache().GetAllPoints()
                                
                                if pCount != op.GetPointCount() :
                                    op.ResizeObject(pCount)
                                
                                MG = mesh.GetMg()
                                op.SetMg(MG)
                                
                                op[c4d.SPLINEOBJECT_CLOSED] = True
                                for i,p in enumerate(points) :
                                    op.SetPoint(i, p)
                                    
                                op.Message(c4d.MSG_UPDATE)

                    return c4d.EXECUTIONRESULT_OK

                    if __name__ == "__main__":
                        path, file = os.path.split(__file__)
                        bmp = bitmaps.BaseBitmap()
                        bmp.InitWith(os.path.join(path, "res", "spaghetti.tif"))
                        plugins.RegisterTagPlugin(id=PLUGIN_ID, str="SF-spaghetti",
                                                    g=spaghettiData,
                                                    description="Osfspaghetti", icon=bmp,
                                                    info=c4d.TAG_VISIBLE|c4d.TAG_EXPRESSION)
                    #############################################

                    1 Reply Last reply Reply Quote 0
                    • H
                      Helper
                      last edited by

                      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                      On 05/07/2011 at 06:32, xxxxxxxx wrote:

                      Sorry for the delay, I'll try to find a solution.

                      cheers,
                      Matthias

                      1 Reply Last reply Reply Quote 0
                      • H
                        Helper
                        last edited by

                        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                        On 05/10/2011 at 05:40, xxxxxxxx wrote:

                        Have there been any news in this regard? I actually had this problem popping up multiple times, but I am not sure if there is a clean solution.

                        This btw. also happens, when the spline objects shape depends on the object transformation. GetCountour isn't called when the transformation changes as well.

                        1 Reply Last reply Reply Quote 0
                        • H
                          Helper
                          last edited by

                          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                          On 04/12/2011 at 03:31, xxxxxxxx wrote:

                          Is there a way to return more than one Spline?

                          1 Reply Last reply Reply Quote 0
                          • H
                            Helper
                            last edited by

                            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                            On 04/12/2011 at 03:56, xxxxxxxx wrote:

                            If you're using GetVirtualObjects to return your splines, just create a null object and make the generated splines child objects of the null. Then return the null.

                            If you have to use GetContour, you can't do that because then you have to return a pointer to a SplineObject, not a BaseObject. So what I do is create a Connect object, make the splines children of that, do a SendModelingCommand with MCOMMAND_JOIN on the Connect object, cast the result to a *SplineObject and return that.

                            The whole issue with GVO and GC is a mess, it should have been fixed years ago. We shouldn't need both, just the generic GVO function.

                            1 Reply Last reply Reply Quote 0
                            • H
                              Helper
                              last edited by

                              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                              On 04/12/2011 at 04:18, xxxxxxxx wrote:

                              Yeah. I've got two other plugins I as working on that are spline-dependent (custom spline IK with rail spline option and one for poly deformation).
                              Another issue I have is that there is no way for me to adjust the execution point of Splines I'm using. (Splines are always set to Generator priority, which heavily limits their use for tags that need priority set to Experssion.)
                              I've yet to hear any news of either an overhaul or at the very least a hack to deal with SplineObjects...

                              1 Reply Last reply Reply Quote 0
                              • H
                                Helper
                                last edited by

                                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                                On 04/12/2011 at 04:32, xxxxxxxx wrote:

                                I don't know if it will help your problem, but there's a hack on my site to deal with the issue of GetContour not being called except when the AM is updated. It might be of some use, you can find it at http://www.microbion.co.uk/graphics/c4d/cookbook-3.htm.

                                1 Reply Last reply Reply Quote 0
                                • H
                                  Helper
                                  last edited by

                                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                                  On 04/12/2011 at 04:51, xxxxxxxx wrote:

                                  Yeah, that would work great! My original setup was to manually add in keyframes in C4D using a dummy Description to force the update. Your solution's much more elegant. I can probably get UberTracer finally running with that one.
                                  I'll start working on it again this week.
                                  Thanks Spedler. 😄

                                  1 Reply Last reply Reply Quote 0
                                  • H
                                    Helper
                                    last edited by

                                    THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                                    On 10/04/2012 at 07:28, xxxxxxxx wrote:

                                    See solution posted here.

                                    1 Reply Last reply Reply Quote 0
                                    • H
                                      Helper
                                      last edited by

                                      On 29/08/2014 at 03:33, xxxxxxxx wrote:

                                      Getting back to updating my plugin after all these years...

                                      It seems that if I call the GetContour() method within the GetVirtualObjects() method, the spline finally updates as expected. The splines also redraw for Sketch & Toon.

                                        
                                      BaseObject *UberTracer::GetVirtualObjects(BaseObject*op, HierarchyHelp*hh){  
                                        return UberTracer::GetContour(op, op->GetDocument(), op->GetDocument->GetLOD(), hh->GetThread());  
                                      }  
                                      SplineObject *UberTracer::GetContour(BaseObject* op, BaseDocument* doc, Float lod, BaseThread* bt){  
                                        /*code for spline generation in here*/  
                                      }
                                      

                                      ...is it safe to code an object this way, or will there be side-effects?
                                      I've tried the CheckDirty workaround and it doesn't really work as I need it to.

                                      1 Reply Last reply Reply Quote 0
                                      • H
                                        Helper
                                        last edited by

                                        On 25/10/2014 at 03:13, xxxxxxxx wrote:

                                        Welp... answering my question, running GetContour() inside GetVirtualObjects() seems to work almost perfectly.

                                        Update calls are regular, and Generators and Sketch & Toon will recognize the spline.

                                        BUT the Hair Renderer will not recognize the spline if GetContour is called in GetVirtualObjects.

                                        I just have to figure out a way to do a CompareDependenceList() call inside GetContour to optimize the redraw calls...

                                        1 Reply Last reply Reply Quote 0
                                        • H
                                          Helper
                                          last edited by

                                          On 25/10/2014 at 08:53, xxxxxxxx wrote:

                                          I think this happens because the Hair engine expects to be fed a SplineObject (as returned by GetContour), but what GVO returns is a BaseObject. As far as I know, and I spent a lot of time on this a couple of years ago, there is no way to make this work because GVO will not return a SplineObject. I mean, obviously it can return a spline but not as a SplineObject, which is a subclass of BaseObject.

                                          Steve

                                          1 Reply Last reply Reply Quote 0
                                          • H
                                            Helper
                                            last edited by

                                            On 27/10/2014 at 01:30, xxxxxxxx wrote:

                                            I guess that does make sense.

                                            Anyways, I'm overhauling my ubertracer code from scratch for R16 and Yannick's CheckDirty() suggestion seems to work so far. I'll just have to do several more case tests to make sure it doesn't break.

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post