• 0 Votes
    3 Posts
    793 Views
    B
    Thanks @m_adam Works as expected. Have a great day ahead!
  • Get a simple polygonal version of any object

    General Talk
    4
    0 Votes
    4 Posts
    1k Views
    S
    Hello, Polygonize() is just using SendModelingCommand() with MCOMMAND_CURRENTSTATETOOBJECT. You can actually see the C++ source in c4d_basedocument.cpp in the cinema.framework. But I don't think that this commands merges all objects into one polygon object. best wishes, Sebastian
  • Tag plugin and Dirty check

    Cinema 4D SDK r20 python
    5
    1
    0 Votes
    5 Posts
    821 Views
    P
    I create a workaround that is working. I think, like you say, that the Subdivision Surface is not ok, when I initially load the scene. I now get the polygon object under the sss and that works.
  • Tag used on multiple objects.

    Cinema 4D SDK python r20
    6
    0 Votes
    6 Posts
    966 Views
    P
    Read() and Write() works. Thanks.
  • Find C4D's directory without C4D

    Cinema 4D SDK python
    9
    0 Votes
    9 Posts
    5k Views
    merkvilsonM
    Thanks, buddy! But the problem is that the most current one is not a way to go. If the user installed the plugin for R16, then the installer should open R16 itself. I'm trying to find and open it by the name, but the name is always different. It can be Cinema 4D / Cinema 4D R16 / Cinema 4D R16 Demo / Cinema 4D Demo / etc. Well. This is considerably easier on windows since I can check if it exists by using os.path.exists() function, but I have no Idea how to do this on Mac.
  • Problems of copying position keyframs to another obj

    Cinema 4D SDK
    5
    0 Votes
    5 Posts
    1k Views
    Q
    @m_adam Thank you for another detailed answer !
  • Retrieve the World Rotation of a Selected Edge?

    Cinema 4D SDK r20 python
    4
    0 Votes
    4 Posts
    1k Views
    ManuelM
    hello, To answer this question if someone want to do it by code. import c4d from c4d import gui # Welcome to the world of Python # Main function def main(): #get the selected object op = doc.GetActiveObject() if not op: raise TypeError("there's no object selected") if not op.IsInstanceOf(c4d.Opolygon): raise TypeError("obj should be a polygon object") #setup neighbor nbr = c4d.utils.Neighbor() nbr.Init(op) #get the selected edge bs = op.GetSelectedEdges(nbr,c4d.EDGESELECTIONTYPE_SELECTION) #maximum number of edge should be number of polygon * 4 sel = bs.GetAll(op.GetPolygonCount() * 4) #get all polygon vadr = op.GetAllPolygons() #init point a and b index to -1 for error check a = b = -1 #initialise a counter to check in sel array. countEdge = 0 #we can check now every edge to find the corresponding points. So for each polygon for i in xrange(op.GetPolygonCount()): #get the polygon information pli = nbr.GetPolyInfo(i) for side in xrange(4): # Test all 4 sides of a polygon # Only proceed if edge is marked # and edge really exists (for triangles side 2 from c..d does not exist as c==d) if pli["mark"][side] or (side==2 and vadr[i].c == vadr[i].d): continue #if the edge is marked as selected in our sel array if sel[countEdge]: if side==0: a=vadr[i].a; b=vadr[i].b elif side==1: a=vadr[i].b; b=vadr[i].c elif side==2: a=vadr[i].c; b=vadr[i].d elif side==3: a=vadr[i].d; b=vadr[i].a countEdge +=1 if a == -1 or b == -1: raise ValueError("points index can't be negatives") #get all points array points = op.GetAllPoints() #Get the direction of the edge in global coordinate (multiply the points'vector by the matrix of the object) opmg = op.GetMg() #i've picked a direction from point a to point b so the angle could need to be reverted. dirVector = points[b]*opmg - points[a]*opmg #normalize a vector is often a good idea. dirVector.Normalize() #transform the vector to hpb note the result is in radian hpb = c4d.utils.VectorToHPB(dirVector) #transform radian to degree hpb.x = c4d.utils.RadToDeg(hpb.x) hpb.y = c4d.utils.RadToDeg(hpb.y) hpb.z = c4d.utils.RadToDeg(hpb.z) print "the edge is poiting to",dirVector,"the corresponding angle is", hpb # Execute main() if __name__=='__main__': main() Cheers Manuel
  • Data Dump Python Function

    Cinema 4D SDK
    9
    0 Votes
    9 Posts
    2k Views
    ManuelM
    hello, if you don't have anything else to add, i'll mark this topic as "solved" Cheers Manuel
  • Saving & Loading User Preset

    Cinema 4D SDK
    3
    0 Votes
    3 Posts
    658 Views
    P
    Hi Maxime, thank you very much! Good to know. I would otherwise searched forever. Cheers, PdZ
  • c4dpy crashes

    Cinema 4D SDK python r20 windows
    4
    1
    0 Votes
    4 Posts
    694 Views
    P
    Ok, I will give it a try and let you know. Thanks.
  • Make Objects Editable (Streamlined)?

    Cinema 4D SDK r20 python
    5
    0 Votes
    5 Posts
    1k Views
    ManuelM
    Just to add some side notes : SendModelingCommand is waiting for a list of objects in case you want to execute that command on several objects. In your case, you only got one element in your list. You can have more informations about list here
  • Buttons ids

    Cinema 4D SDK python
    2
    0 Votes
    2 Posts
    784 Views
    ManuelM
    Hello, there's no real list where you can find easily those IDs. @m_adam came with this idea : open the Script log (menu script > script log) and click the button you want to call. in the console you will see something like c4d.CallButton(tool(), c4d.MDATA_NEWTRANSFORM) so you know that the ID is c4d.MDATA_NEWTRANSFORM Another place to look for, is the folder ressource/modules where you can find the files .res that build the ui. (using your OS search function will help a lot) Openning those file you will find the information BUTTON MDATA_NEWTRANSFORM { FIT_H; } and you can maybe open the file with the same name with the extention .h where you will find the id MDATA_NEWTRANSFORM = 701, // Button Other than that, there are the enums on the documentation like this page but it's not really "user friendly" Let me know. Cheers Manuel
  • Cinema Gradient, weird behaviour

    Cinema 4D SDK r20 sdk python
    7
    0 Votes
    7 Posts
    1k Views
    M
    Don't feel sorry yes this is the issue and since Knot ID are not ordered from right to left but from creation order its why it's confused you. Moreover, using a for loop will make way more sense and help you to avoid this kind of stuff. grad1 = shdr1[c4d.SLA_GRADIENT_GRADIENT] grad2 = shdr2[c4d.SLA_GRADIENT_GRADIENT] for knotId in xrange(grad1.GetKnotCount()): knot = grad1.GetKnot(knotId) grad2.InsertKnot(col=knot['col'], pos=knot['pos'],index=knot['index']) grad2.FlushKnots() shdr2[c4d.SLA_GRADIENT_GRADIENT] = grad2 Finally, a BaseShader is derived from BaseList2D which is derived from C4DAtom that mean you can use GetClone to retrieves a clone of this shader so your code can look like. import c4d def main(): mat = doc.GetFirstMaterial() colorShader = mat[c4d.MATERIAL_COLOR_SHADER] if colorShader is None: return copyColor = colorShader.GetClone() mat[c4d.MATERIAL_DIFFUSION_SHADER] = copyColor mat.InsertShader(copyColor) mat.Message(c4d.MSG_UPDATE) mat.Update(True, True) c4d.EventAdd() # Execute main() if __name__=='__main__': main() Cheers, Maxime.
  • 0 Votes
    5 Posts
    940 Views
    B
    @m_adam Thanks for further clarification specially the catch with the dialog's on the script. Will now closed the thread. Have a great day ahead!
  • Use a list or array for data?

    General Talk python
    5
    1
    0 Votes
    5 Posts
    2k Views
    ManuelM
    hello, if you don't have anything else to add, i'll mark this topic as "solved" Cheers Manuel
  • Add/Remove Groups of User Data

    Cinema 4D SDK python
    12
    2
    0 Votes
    12 Posts
    4k Views
    mrittmanM
    @m_magalhaes said in Add/Remove Groups of User Data: Hello, I was also talking about something like this. But it's not the best way to go. I suggest a TagData (plugin) with his own UI. pyTagCode = '\ import c4d \n\ #Welcome to the world of Python \n\ \n\ def main():\n\ print "this ia a message"\n\ \n\ ' import c4d # Main function def main(): if op is None: gui.MessageDialog("Please selecte a target object") tag = c4d.BaseTag(c4d.Tpython) tag[c4d.TPYTHON_CODE] = pyTagCode op.InsertTag(tag) c4d.EventAdd() # Execute main() if __name__=='__main__': main() By the way, don't forget you can save tag presets, that include python tags. You can simple add them with right click on your object in OM and "Load tag preset" Cheers, Manuel Oh this is good to know! Thanks so much for the information, this is quite helpful! Matt
  • Access Custom User Data By Name (not by ID)

    Cinema 4D SDK r20 python
    5
    0 Votes
    5 Posts
    1k Views
    B
    Thanks for the response @m_adam Have a great day ahead!
  • How to cancel FileLoad error message.

    Cinema 4D SDK
    3
    0 Votes
    3 Posts
    783 Views
    V
    Thanks for the reply! I'll try that, though I thought that SCENEFILTER_IGNOREXREFS would keep xrefs from being loaded, and since my plugin edits the xref path/name, this would not work. But then again, perhaps I assumed wrong. I appreciate the help! By the way, the idea of classification by tags appears to be a good way to escape the messy folding out tree of classification system that we are all used to. I'll use it next time.
  • The python SDK is running in error

    Cinema 4D SDK sdk c++ python
    2
    1
    0 Votes
    2 Posts
    503 Views
    r_giganteR
    Hi panney, thanks for reaching out us. With regard to the issue you're experiencing, it's pretty likely that the cause is a different revision between the c4dpy executable and the Cinema 4D revision. Please be sure that they both matches (20.059 c4dpy is available here[URL-REMOVED]). Last but not least, here you can find more detail on the c4dpy executable. Best, R. [URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.
  • Move viewport camera from plugin

    General Talk
    5
    0 Votes
    5 Posts
    1k Views
    D
    wow! i love that. great job!