• IsEqual not defined

    r20 c++
    3
    0 Votes
    3 Posts
    724 Views
    C4DSC
    @m_magalhaes said in IsEqual not defined: MAXON_OPERATOR_EQUALITY(Int32Pair, a, b); Thanks, didn't know about the MAXON_OPERATOR_EQUALITY. Very handy indeed. However, I had already tried providing an equality operator in my Int32Pair class, as such: Bool operator == (const Int32Pair& other) { return (a == other.a) && (b == other.b); } But that still resulted in the "IsEqual not defined" compiler error. The macro, however, is working fine. Looking further at my implementation of operator==, I now notice I didn't declare it as a const method. Adding the const does get rid of the compiler error. Oh boy! Overlooked a minor "typo", with major consequences. Again, thanks for the macro.
  • How to get InExcludeData in ModifyObject

    r20 c++
    4
    0 Votes
    4 Posts
    1k Views
    M
    @m_magalhaes Thank you for your answer. really helpful!
  • Tag used on multiple objects.

    python r20
    6
    0 Votes
    6 Posts
    1k Views
    P
    Read() and Write() works. Thanks.
  • Baking textures for PBR object

    2
    0 Votes
    2 Posts
    1k Views
    r_giganteR
    Hi krftt thanks for reaching out us. With regard to your question, if the intent is to bake the final appearance of a PBR material on a texture, I confirm that there are no means to achieve this considering that the baked data will also be camera-dependent. If, on the contrary, your goal is to sample the shader used in any of the reflection layers used in a PBR material you can consider BaseShader::Sample() and, given a ChannelData, retrieve the color at a specific point - see this thread. To browse through the different channel you can use something like: # check for an active material mat = doc.GetActiveMaterial() if mat is None: return # retrieve the reflection layers count layersCount = mat.GetReflectionLayerCount() # loop through the layers for i in xrange(layersCount): # get the ReflectionLayer instance and the related data ID reflLayer = mat.GetReflectionLayerIndex(i) reflLayerData = reflLayer.GetDataID() # check for the instance to be the one currently active in the Attribute Manager if reflLayer.GetFlags() & (c4d.REFLECTION_FLAG_TAB): # retrieve the color color = mat[reflLayerData + c4d.REFLECTION_LAYER_COLOR_COLOR] # try to retrieve the shader colorShader = mat[reflLayerData + c4d.REFLECTION_LAYER_COLOR_TEXTURE] # do something with the data retrieved if colorShader is None: print "Selected layer is ", reflLayer.GetName(), "and uses color: ", color else: print "Selected layer is ", reflLayer.GetName(), "and uses shader: ", colorShader.GetName() Best, Riccardo
  • How to updata message when i save data in NodeData::Message

    r20 c++
    4
    0 Votes
    4 Posts
    1k Views
    M
    @r_gigante Oh!Thank you!The plug-in ID is the reason for the problem,use another shorter number and everything is ok. Thank your for your help!
  • modulo - behind the scenes

    r19 r20 c++
    3
    0 Votes
    3 Posts
    679 Views
    C4DSC
    Thanks for the info.
  • Unable to kill my C4DThread

    8
    0 Votes
    8 Posts
    2k Views
    r_giganteR
    Hi Mafster, thanks for following up. The documentation here properly indicates that passing no parameter to Wait() is passing True. Long story short, this value is required in order to avoid Cinema being stuck on waiting for the thread to end. Hoping this helps in solving the issue, give best. Riccardo
  • Python - Cinema 4D R20.057 - Export to Alembic without Dialog

    python r20
    6
    0 Votes
    6 Posts
    2k Views
    P
    Yes it is! Thank you very much!
  • Problems of copying position keyframs to another obj

    5
    0 Votes
    5 Posts
    2k Views
    Q
    @m_adam Thank you for another detailed answer !
  • c4dpy crashes

    python r20 windows
    4
    1
    0 Votes
    4 Posts
    839 Views
    P
    Ok, I will give it a try and let you know. Thanks.
  • Retrieve the World Rotation of a Selected Edge?

    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
  • This topic is deleted!

    1
    0 Votes
    1 Posts
    3 Views
    No one has replied
  • Saving & Loading User Preset

    3
    0 Votes
    3 Posts
    850 Views
    P
    Hi Maxime, thank you very much! Good to know. I would otherwise searched forever. Cheers, PdZ
  • Cinema Gradient, weird behaviour

    r20 sdk python
    7
    0 Votes
    7 Posts
    2k 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.
  • How to keep data in tag plugin even if restart Cinema 4D

    python
    7
    0 Votes
    7 Posts
    2k Views
    M
    Please consider to sets the topic as solved if it's the case. Cheers, Maxime. EDIT: I've done it, but feel free to set it back to Open if you feel the need to ask more questions.
  • Make Objects Editable (Streamlined)?

    r20 python
    5
    0 Votes
    5 Posts
    2k 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
  • Node-Based Materials

    r20 sdk windows
    6
    0 Votes
    6 Posts
    2k Views
    M
    As stated before, we are working on it and it will be released in the future. I can't say more. Regarding your question @Aaron this will be possible.
  • Buttons ids

    python
    2
    0 Votes
    2 Posts
    1k 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
  • Dialogue Box/Manager through Plug-in vs Vanilla Script?

    r20 python
    5
    0 Votes
    5 Posts
    1k 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!
  • Cinema 4D R20.059 bug with many RegisterShaderPlugin() calls

    r20 windows c++
    7
    0 Votes
    7 Posts
    4k Views
    A
    Hi Riccardo, I think the issue is solved because there is no any issue. Some not good methods of software distribution just confused us. Btw, what benefits different parameters of SetPluginPriority() give to us? For example the xdll has several plugins like materials, shader, tags and renderer. Even some icons with plugin ids. What priority is better to use in this case? I see https://developers.maxon.net/docs/cpp/2023_2/page_manual_module_functions.html For example, what is C4DPL_INIT_PRIORITY_ADVANCEDRENDER: Does it give higher thread priority during some PV rendering task? Or does it just load the plugin before other renderers and give the chance to lock system resources before others?