Navigation

    • Register
    • Login
    • Search
    1. Home
    2. Helper
    H

    Helper

    @Helper

    1
    Reputation
    -6
    Posts
    701
    Profile views
    1
    Followers
    0
    Following
    Joined Last Online

    • Profile
    • More
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups
    Helper Follow

    Best posts made by Helper

    RE: Get outer edges of each Ngon

    On 23/01/2018 at 14:05, xxxxxxxx wrote:

    Hi Frank, thanks for writing us and above all sorry for coming late here.

    With regard to your question the methods pointed out in the post you're referring to, are actually only paving the first part of the road to get the external (outer) edges of a n-gon.

    A short recap, for those not familiar with n-gons, on the terminology i'm going to use down below:
    - n-gon: a face made of more than 4 edges and made up of at least two polygons sharing an internal edge (like the object on the left made up of poly 0,1,2,3,4,5);
    - polygon: a face made of 3 or 4 edges (like poly 6 and 7 on the object on the right);
    - face: a polygon or a n-gon;
    - external edge: an edge which define the outer or inner boundary of a face and represented when Wireframe Display mode is active (all green numbers marked with a orange circle);
    - internal edge: an edge which is shared across the polygons building up a n-gon (all the remaining green numbers)
    - vertex/point: the start or end point of an edge (marked in red numbers).

    It's also worthy to note that only n-gon can contain holes and can be concave (tracing a generic segment in the ngon might end in intersecting the ngon external outer/inner edges multple time) whilst a simple polygon cannot have holes and can be only convex (tracing a generic segment in the polygon will never end in intersecting the polygon external outer edges). For the sake of completeness, PolygonObjects which are made of multiple polygons or ngons can instead create holes and be concave as well.


    My solution to find the outer edge is conceptually simple:

    1. identify edges which are external (inner or outer doesn't matter);
    2. in case the PolygonObject is made by multiple polygons or ngons, identify those edges already marked external at point 1 which are shared across two faces (like edge marked in purple) and mark them as internal;
    3. walk across the list of the external edges and create an ordered lists of edges which are:
      * external;
      * are connected in CW or CCW order;
    4. split the list in multiple lists to create the different islands;
    5. compute the area of each island (projected on a 2D-plane) and identify the biggest one which represent the island of the outer edges.

    The PolygonObject.GetNgonEdgesCompact() is helpful to mark which edges are internal or external in a PolygonObject made by just one n-gon.

    At the same time Neighbor.GetNeighbor() is helpful to  distinguish those external edges which are mutually used by a polygon and a n-gon (or two n-gons or two polygons) from those actually representing the real "external" boundary or a PolygonObject (like those in purple in the image above).

    So far i don't think that either PolygonObject.GetPolygonTranslationMap() or PolygonObject.GetNGonTranslationMap() are needed, but maybe approaching the problem from a different perspective could be helpful as well.

    Hope these few lines could help.

    Best, Riccardo

    posted in PYTHON Development •

    Latest posts made by Helper

    Script Write to Annotation Tag on Save

    On 31/08/2018 at 07:42, xxxxxxxx wrote:

    I can't seem to figure out how to get
    MSG_DOCUMENTINFO_TYPE_SAVE_BEFORE
    to trigger.

    I would like to save some info to an Annotation tag, but only right before the user saves the document.

    Tried to put it in Message() but couldn't figure out if Message can stand by itself or if it has to be in a NodeData class?

    class SampleClass(plugins.NodeData) :
        def Message(self, node, type, data) :
            if type == c4d.MSG_DOCUMENTINFO:
                if data['type'] == c4d.MSG_DOCUMENTINFO_TYPE_SAVE_BEFORE:
                    print "Document is about to save"
                    return True
                return True
    

    Thanks

    posted in PYTHON Development •
    RE: Outline selection?

    On 31/08/2018 at 05:31, xxxxxxxx wrote:

    Hi fnoller,

    I'm afraid, as mentioned here there is no direct way to use our internal command for select outline.
    You get a basic implementation of the comment from Donovan by Cesar Vonc [URL=https://code.vonc.fr/?a=100#f-SelectionneAretesContour] which might help you.

    If you have any question please let me know.
    Cheers,
    Maxime!

    posted in PYTHON Development •
    Outline selection?

    On 30/08/2018 at 13:12, xxxxxxxx wrote:

    Hi all,

    How can I select the outline edges of selected polygons in python, just like the command "Outline Selection"?

    Best regards

    Fnoller

    posted in PYTHON Development •
    RE: Art shader, or load from content browser ?

    On 31/08/2018 at 04:07, xxxxxxxx wrote:

    Hi Myosis, first of all, welcome in the plugincafe community!

    Even if shader didn't get a proper symbols name, each BaseList2D get an ID. And symbols only refer to this ID.
    So if you want to know the current ID of an Art shader. Simply create a shader in a material, then drag and drop the channel where the shader is into the console. Press enter and it will print you the ID.
    For the art shader, it's 1012161.

    About bitmap do the same technique, simply drag and drop the parameter into the console to know the parameter ID.

    Then you can create it using the following script

    import c4d
      
    def main() :
        mat = doc.GetActiveMaterial()
        if not mat:
            return
        
        # Create the bitmap shader
        bmpShader = c4d.BaseShader(c4d.Xbitmap)
        bmpShader[c4d.BITMAPSHADER_FILENAME] = "YourTexturePath"
        
        # Create a art Shader and insert our bmp shader
        artShader = c4d.BaseShader(1012161)
        artShader.InsertShader(bmpShader)
        artShader[c4d.ARTSHADER_TEXTURE] = bmpShader
        
        # Then insert our art Shader into the active material, and use it in the color channel
        mat.InsertShader(artShader)
        mat[c4d.MATERIAL_COLOR_SHADER] = artShader
        
        c4d.EventAdd()
      
    if __name__=='__main__':
        main()
    

    As you already figured out, in python the only way to load stuff from content browser is to use LoadFile/MergeDocument.

    If you have any question, please let me know!
    Cheers,
    Maxime!

    posted in PYTHON Development •
    RE: Art shader, or load from content browser ?

    On 30/08/2018 at 23:11, xxxxxxxx wrote:

    I figured out how to load the material form the content browser:

    > doc = c4d.documents.GetActiveDocument()
    >
    > location = "preset://somefolder.lib4d/mymat"
    >
    > c4d.documents.MergeDocument(doc, location, c4d.SCENEFILTER_MATERIALS)

    But I prefer creating the material in python rather then loading it, if anyone knows how to access and apply the Art shader, let me know 😉

    - Tim

    posted in PYTHON Development •
    Art shader, or load from content browser ?

    On 30/08/2018 at 02:01, xxxxxxxx wrote:

    Hi,

    First off I'm new here, and also very new with python.
    I'm trying to create a pretty basic material using python, but it seems not so easy.

    I have two questions:
    How can I add the Art shader to a channel?

    It's not listed in the SDK shader list.
    So it's probably not like I'm just missing the right word here, is it ?

    > matt[c4d.MATERIAL_USE_LUMINANCE] = True
    >
    > Art = c4d.BaseList2D(c4d.X...something.....)
    >
    > matt.InsertShader( Art )
    >
    > matt[c4d.MATERIAL_LUMINANCE_SHADER] = Art

    I also want it to load a image in the art shader, so I figured, why don't I just create a preset folder in the content browser and load the material form that folder. 
    Turns out it's quite tricky to import materials from the content browser too.

    > fn = "preset://somefolder/Cube.2.c4d"
    >
    > c4d.documents.LoadFile(fn)

    If I use anything else then LoadFile, it will tell me to use a base document in the console.

    From my understanding, I have to make a virtual base document and then import it from that.
    How does that look like in code ?

    I only need one to work, but I am very interested in both!

    Cheers,
    Tim

    posted in PYTHON Development •
    RE: Rectangle selection BUG

    On 30/08/2018 at 10:47, xxxxxxxx wrote:

    Hi,

    as Sebastian already pointed out last time, this is a forum for 3rd party developers. We can not help you with bugs not related to the SDKs here. Please contact our user support via the form on our main website: How can we help?

    posted in Bug Reports •
    Rectangle selection BUG

    On 29/08/2018 at 13:58, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   19 
    Platform:   Windows  ;   
    Language(s) :       PYTHON  ;

    ---------
    Still Cinema have a GREAT BUG of simple selection

    video of a bug
    https://youtu.be/pCJ07kC1dSs
    https://youtu.be/pCJ07kC1dSs

    posted in Bug Reports •
    RE: Launch color picker dialog

    On 30/08/2018 at 11:15, xxxxxxxx wrote:

    Hi,

    if I understand correctly, you want the entire Color Picker dialog, not just the color picker "action" you get, when clicking onto the pipette icon in color chooser, right?
    The color picker dialog can be opened with GeChooseColor(). The color pick action on the other hand is implemented internally and can not be started via the API.

    posted in SDK Help •
    Launch color picker dialog

    On 29/08/2018 at 05:26, xxxxxxxx wrote:

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

    ---------
    Hello.

    I have my custom GeUserArea in a CustomGui parameter.
    I want to click that User Area and launch the Color Picker modal dialog as happens with ColorField dialog parameter or COLOR description parameter.

    Can I do that ?

    Thank you.

    posted in SDK Help •