• 0 Votes
    2 Posts
    1k Views
    S
    Hello, you cannot create a Material in the main() function of a Python Generator object. The main() function of the Python Generator object defines a cache of "virtual" BaseObjects which will appear in the scene. Materials cannot be created this way. A material must be inserted into the BaseDocument. This must only happen from the main thread, typically in reaction to some user interaction. One way of doing this would be to add a user data button to your Generator. Then your user could simply press that button to create the needed materials. Pressing the button can be detected by implementing the message() function. This could look like this: def main(): # search for material mat = doc.SearchMaterial("Generator Material") if mat is None: return None # create object cube = c4d.BaseObject(c4d.Ocube) # apply material ttag = cube.MakeTag(c4d.Ttexture) ttag[c4d.TEXTURETAG_MATERIAL] = mat return cube def message(id, data): if id == c4d.MSG_DESCRIPTION_COMMAND: buttonId = data['id'] # check button ID if buttonId[1].id == 1: # create material and insert it into the host document c4d.StopAllThreads() material = c4d.Material() material.SetName("Generator Material") material[c4d.MATERIAL_COLOR_COLOR] = c4d.Vector(1,0,0) doc.InsertMaterial(material, None) c4d.EventAdd() Also, please use the Q&A system. best wishes, Sebastian
  • 0 Votes
    4 Posts
    1k Views
    S
    @stevejlv I found a workaround: the value part in the value;string Cycle option list does not have to be 0,1,2 etc. So I can give them the exact value as the string part (as long as they are int) and get the value I want the old fashioned way: [c4d.ID_USERDATA,1]
  • 0 Votes
    4 Posts
    1k Views
    CairynC
    @bentraje Yeah, the second part was meant just in case you have need for a manual process. GetModelingAxis() takes multiselections of elements into account. However, I believe GetModelingAxis() works by selected mode (as you can have different selections for points, polys, and edges in parallel depending on whether the point, poly, edge, or object mode is active. So if you explicitly need the point selection and use the method in a script, you may want to switch to the point mode before using GetModelingAxis(). (Also, the actual modeling axis can be changed by the tools, so caution is in order. Personally, this is the behavior I needed, so I didn't make any big experiments.)
  • 0 Votes
    2 Posts
    685 Views
    P
    Together with the help from the c4dlounge.eu forum the issues is solved. The main issue was I did not read the manual good enough. "Note that Size symbolizes the axis size and not the expansion of the object itself. For planar projections, the true dimension is the two/fold of the axis length."
  • 0 Votes
    5 Posts
    1k Views
    M
    thanks solved: self.data = {'sphere_size': 15, 'extension_ratio': 1, 'extend_vector': False} kind regards
  • Changing DATETIME_GUI date format

    Cinema 4D SDK python r19
    3
    1
    0 Votes
    3 Posts
    796 Views
    A
    @s_bach Hi Sebastian, Thanks for your help! That makes sense! Andre
  • 0 Votes
    6 Posts
    2k Views
    B
    @Cairyn Interesting "(not just on every frame but far more often)" I guess for now I guess I'll just do it in piecemeal. Other parts in Xpresso nodes and the other python tag. Thanks for the tip on the Python nodes on the Xpresso editor. Haven't tried it. I would go for the pure Xpresso set-up but its a bit finicky to set-up such as identifying where the node sits in the xpresso editor otherwise it sits on top of each other (An automatic layout command would be nice). @m_adam Thanks for the reference!
  • 0 Votes
    3 Posts
    619 Views
    M
    This issue is now fixed in R21. So you don't need to manually SetDirty / Send the message. Cheers, Maxime.
  • 0 Votes
    3 Posts
    1k Views
    M
    Hi @SteveJLV welcome in the plugincafe community, I would like to point you to some rules: Read Before Posting. Nothing wrong here, but just in case. Q&A New Functionality. I've setup your topic correctly. As you already figured it out, you never assign a new value to the variable. In Python, everything is passed by value by default in 90% of the time. Meaning when you do x = y will actually copy y to x, so afterward if you do x + 10 it will not affect y value. If you have more questions, don't hesitate. Cheers, Maxime.
  • 0 Votes
    8 Posts
    3k Views
    M
    @bentraje said in Get World Position of Obj A's position and Set it to Obj B's position: RE: main function Just wondering does it have to be in a main function (like literally the name of the function is main) or just inside the if __name__=='__main__':? Does C4D places special treatment to the word "main"? I was confused at that previously and later realized that if __name__=='__main__': is not specific to C4D but used in python in general in checking if the script is referenced to other script, which I don't do at the moment. So I just skip it. So would this code be just fine? if __name__=='__main__': executeMe() Yes this is correct.
  • Getting a pointer to a UserArea

    Cinema 4D SDK python r19 r20
    5
    0 Votes
    5 Posts
    980 Views
    S
    Hello, I don't have a Cinmea 4D R14 version so I can't test that case. But in R20 some symbols have changed. E.g. c4d.DESCFLAGS_SET_0 was changed to c4d.DESCFLAGS_SET_NONE. Similarly, c4d.USERAREAFLAGS_NONE was c4d.USERAREA_0. best wishes, Sebastian
  • Triangulate geometry when exporting a fbx

    Cinema 4D SDK r20 python
    2
    0 Votes
    2 Posts
    900 Views
    M
    Hi @Rage, I think this question is related to the another topic you posted, so I will not explain again how import/export works in CInema 4D. In your case, you have to use FBXEXPORT_TRIANGULATE and not FBXEXPORT_TRIANGULATE_GEOMETRY. And yes you are right, currently, no symbol is defined for the FBX exporter so you have to use 1026370 directly. Cheers, Maxime.
  • Set options when importing a file

    Cinema 4D SDK r20 python
    2
    0 Votes
    2 Posts
    806 Views
    M
    Hi @rage, you first have to configure the exporter plugin then Load the document/ Merge it. Cinema 4D will automatically use the settings you defined in the plugin. You can find examples of the procedure in our github repository. Finally, symbols for supported exporter/importer are exposed in this page of the Python documentation. Unfortunately, there is no area describing each symbol for each exporter in the python documentation, but you can find them using the search engine in the C++ documentation. (I linked you the C++ symbols of OBJ, import) If you have any questions, please let me know. Cheers, Maxime.
  • Universal "Undo" to Rule them All?

    Cinema 4D SDK r20 python
    15
    0 Votes
    15 Posts
    5k Views
    B
    @Cairyn Thanks again for the detailed explanation. I'll put this to rest. At least for now I know the limitation and the commands to avoid. @s_bach Thanks for the confirmation. Have a great day ahead!
  • Registering tokens in python

    Cinema 4D SDK windows python r20
    4
    0 Votes
    4 Posts
    900 Views
    r_giganteR
    Hi line6dude, thanks for following up. With regard to registering Tokens in c++, given that it's not a complex task, requires at least a minimum background of C++, familiarity with Xcode (or VisualStudio) and understanding of our Cinema 4D tool-chain. If you feel comfortable in becoming familiar with such concepts, please open a new thread to tackle the argument. Best, Riccardo
  • 0 Votes
    7 Posts
    2k Views
    B
    @C4DS Works as expected. Phew! I never knew it is this complicated. Thanks again. Have a great day ahead!
  • 0 Votes
    4 Posts
    2k Views
    B
    @mp5gosu Thanks for the response and for the link regarding recursive and nonrecusive distinction, but I think the recursive version is shorter to write @Cairyn Thanks for the revised script. Works as expected. To be honest, I really do not know Python in C4D per se. I'm just winging it. Hahaha. So, thanks for the explanation!
  • GeDialog.GetType() Missing Link

    Cinema 4D SDK python
    2
    0 Votes
    2 Posts
    576 Views
    M
    Hi, @merkvilson thanks for pointing this function is private and have no use case since its return the type of a c4d.gui.Gadget which is only used internally. Cheers, Maxime.
  • 0 Votes
    9 Posts
    3k Views
    M
    This issue is now fixed in R21. Cheers, Maxime.
  • 0 Votes
    5 Posts
    1k Views
    B
    Gotcha. Thanks for clarification!