• Command() does not honor Dynamic Lists/Variable

    Cinema 4D SDK r21 python
    9
    0 Votes
    9 Posts
    920 Views
    B
    When you presented the order of execution of __init__(), CreateLayout and InitValues. That makes total sense especially the 2.2.1 when it resets to an empty list. Thanks for the clarification!
  • Drag&Drop an image in a gui field

    Cinema 4D SDK r20 python
    5
    1
    0 Votes
    5 Posts
    1k Views
    D
    @pim I'm trying to figure out how you did this. Could you please share a sample code of this example? I'm trying to get the full path of an image by dragging it into a edit text field... Cheers
  • How to Generate Dynamic Functions?

    General Talk r21 python
    3
    0 Votes
    3 Posts
    557 Views
    B
    Gotcha. Thanks for the code and confirmation. For my code, it's not really a simple printing the ID. Each ID corresponds with a separate function/script. I guess I'll just store them in a separate list. Separate ID list and separate function script list. Then execute them by matching index.
  • Retrieving Link from Hyperfile

    Cinema 4D SDK python sdk
    3
    1
    0 Votes
    3 Posts
    462 Views
    ?
    Thank you @r_gigante for the reply! Sorry if the intent is unclear: this self-contained script was something I came up with last night to demonstrate an issue I'm having in my plugin which is too many scripts to post to the forums. Since the user can't select an object after the script is running, I added that catch to make sure an object was selected to show what was going wrong. My Goal I am trying to save a link to a scene object and its matrix to a hyperfile so the user can load the hyperfile in another session and restore the link to the object so that I can apply the saved matrix. I don't need the object itself. Update I updated the original script's GetLink() method to pass a reference to the active document, but that did not solve the issue.
  • Cant select newly created Instance

    Cinema 4D SDK python
    7
    0 Votes
    7 Posts
    1k Views
    esanE
    @blastframe Ok was able to retrofit your version to get what I wanted, a bit of guesswork in here, but got the result im after lol import c4d from c4d import gui def createInstance(): obj = op.GetDown() inst = c4d.BaseObject(c4d.Oinstance) # created Instance with Base Object inst[c4d.INSTANCEOBJECT_LINK] = obj # set Instance's reference link # set the name using the object passed to the function inst[c4d.ID_BASELIST_NAME] = "%s Instance"%obj[c4d.ID_BASELIST_NAME] return inst # return the Instance instance def AddLongDataType(obj): # create User Data Container named Picker if obj is None: return bc = c4d.GetCustomDataTypeDefault(c4d.DTYPE_LONG) bc[c4d.DESC_NAME] = "Picker" doc.AddUndo(c4d.UNDO_CHANGE, obj) obj.AddUserData(bc) c4d.EventAdd() def setQuickTab(obj, inst, data): # change User Date container to type Cycle, populate with Children Names descid = data[0][0] bc = data[0][1] children = obj.GetChildren() # Build new cycle options container dynamically cycle = c4d.BaseContainer() for i,child in enumerate(children): cycle.SetData(i, child.GetName()) bc[c4d.DESC_CYCLE] = cycle doc.AddUndo(c4d.UNDO_CHANGE, obj) # Set modified description data container inst.SetUserDataContainer(descid, bc) def main(doc): obj = doc.GetActiveObject() if (obj == None): gui.MessageDialog("Please select the Root of the Assets you wish to Instance.") return doc.StartUndo() inst = createInstance() doc.InsertObject(inst) AddLongDataType(inst) data = inst.GetUserDataContainer() setQuickTab(obj, inst, data) doc.AddUndo(c4d.UNDO_NEW, inst) doc.EndUndo() c4d.EventAdd() if __name__=='__main__': main(doc)
  • Dragging an object from a treeview

    Cinema 4D SDK r20 python
    4
    1
    0 Votes
    4 Posts
    625 Views
    P
    Thanks, sounds a bit complicated, so I have to give it some thoughts. For now, it is enough. -Pim
  • Treeview and Right Click

    Cinema 4D SDK python r20
    3
    1
    0 Votes
    3 Posts
    420 Views
    P
    @mp5gosu said in Treeview and Right Click: RemoveData() Great, thanks.
  • Right Click Contextual Menu on a Button?

    Cinema 4D SDK r21 python
    3
    0 Votes
    3 Posts
    624 Views
    B
    @m_adam Works as expected! Thanks again for the sample code, makes everything clear.
  • Free Form GUI Design Layout?

    Cinema 4D SDK r21 python
    5
    0 Votes
    5 Posts
    682 Views
    B
    @r_gigante Thanks for the response. Unfortunately, I still can't read C++ codes at the moment. Is there a python equivalent of that page? I can't seem to see one. There is a page for that but it's like a dictionary. It does not contain any sample codes like in C++ If it does not exist, do you have any C++ with an equivalent Python page in the documentation? I'll just to interpolate them as much as possible. ########################## I also checked the Github sample and it does contain a GeUserArea sample But the button part is still in GeDialog. Is it possible to make the GeUserArea part to be clickable like a button?
  • 0 Votes
    3 Posts
    945 Views
    r_giganteR
    Hi jhpark, thanks for reaching out us. Aside from the notes left by @blastframe - thanks dude for the remarks - I think it's worthy, thinking of a more generic scene, to mention the need BaseDocument::ExecutePasses() to be sure that everything is actually evaluated before querying the scene rather than the EventAdd() which serves a different scope. This function is responsible to execute the scene evaluation and, consequently to be sure that, moving from a frame to another, all the items in the scene reflect the changes imposed by the frame switch. The approach used by @blastframe actually operates on CTracks and key but, although this approach works fine for your specific case, when more evaluation dependencies are created in the scene you could easily end up in unexpected results. The code could then look like frames_count = 10 # [Set] frames counter for f in range(0, frames_count): doc.SetTime(c4d.BaseTime(f, doc.GetFps())) # evaluate the scene doc.ExecutePasses(None, True, True, True, c4d.BUILDFLAGS_NONE) obj = doc.SearchObject('Cube') # get object position x = int(obj.GetMg().off.x) y = int(obj.GetMg().off.y) z = int(obj.GetMg().off.z) # get object color r = int(obj[c4d.ID_BASEOBJECT_COLOR].x * 255) g = int(obj[c4d.ID_BASEOBJECT_COLOR].y * 255) b = int(obj[c4d.ID_BASEOBJECT_COLOR].z * 255) print("Frame = " + str(f) + ", (X,Y,Z) = " + str(x) + "," + str(y) + "," + str(z) + ", RGB = " + str(r) + "," + str(g) + "," + str(b))
  • Stacking Tabs Menu?

    Cinema 4D SDK r21 python
    7
    0 Votes
    7 Posts
    826 Views
    B
    @r_gigante Thanks for the response. RE: Extending to get it working for more than one should be trivial. Unfortunately, the whole code is trivial to me being novice. Anyhow, I guess I'll just learn on QuickTabCustomGui on a separate thread. RE: With regard to the "stacked" tabs functionality, as said above Yes, you did. I was wondering if there is an option for the TabGroupBegin as that is somewhat straight forward to me rather than the QuickTabCustomGui. So I guess, this confirms that it is not possible for the TabGroupBegin. Again, no further action required. Will just open another thread for the QuickTabCustomGui.
  • Tips for GeDialog GUI ID Management?

    General Talk r21 python
    4
    0 Votes
    4 Posts
    702 Views
    B
    Thanks for the response @mp5gosu Yea, this "another level of abstraction" might bite me in other sections of the code but this is the only way I can be sane for now. hehe @m_adam RE: it's also advised to use only iD superior to 1000. Thanks for the note. RE:here is one of the few possible ways The code works as expected. Thanks again! Should make things easier now
  • 0 Votes
    13 Posts
    3k Views
    M
    SaveDocument is already present in the original code in the extended threading class "ExportThread" TO not make it happens in a thread. So to directly execute it in ExecuteConversion. The use of SendCoreMessage is a way, from a thread (and it's the case for you in ExportThread::Main) to send a message, that Cinema 4D will process on the Main thread (I didn't use in my code because in my case I'm in the main thread). So you can react to this message and do something (in your case SaveDocument). It was just for your information, regarding what's your thread is doing (only calling SaveDocument) I would say that using a thread here make no sense, and you should directly call SaveDocument in your ExecuteConversion function. Hope it's more clear. Cheers, Maxime.
  • Update GeDialog When Button is Pressed?

    Cinema 4D SDK r21 python
    6
    0 Votes
    6 Posts
    694 Views
    B
    RE: So if it recreates the same things it is probably because images are not local to your class but only to your function, Ah, gotcha. Thanks for the heads up. Works now as expected
  • Simple way to save images?

    Cinema 4D SDK r21 python
    5
    0 Votes
    5 Posts
    568 Views
    M
    @bentraje said in Simple way to save images?: Union This means it can be either a str or either a c4d.storage.MemoryFileStruct. (Both don't really make sense). Cheers, Maxime.
  • Modify Preferences of an Third Party Plug-in?

    Cinema 4D SDK r21 python
    3
    0 Votes
    3 Posts
    346 Views
    B
    Hi @zipit Thanks for the response. The thread reference works as expected. Here is the code I used: op = plugins.FindPlugin(1027974) # Retrieved from the script log if op: print op[c4d.XPPREFS_SYSHUD_SHOW] # we know the enum from the console Have a great day ahead!
  • Drag & Drop to Reorder in GUI

    Cinema 4D SDK python
    14
    0 Votes
    14 Posts
    2k Views
    ?
    @m_adam Terrific work, Maxime! This is very helpful to me and I'm sure the many others who want to learn about dragging in Cinema 4D's UI. Excellent job!
  • GUI Layout Issues

    Cinema 4D SDK python sdk
    4
    2
    0 Votes
    4 Posts
    610 Views
    ?
    @m_adam You are a legend! I've learned a lot about UI in Cinema 4D from this post, thank you very much.
  • Insert object in Treeview

    Cinema 4D SDK r20 python
    4
    0 Votes
    4 Posts
    1k Views
    P
    Thanks, great explanation! One small issue. Delete doesn't work because objParent' is not defined. Traceback (most recent call last): File "scriptmanager", line 251, in DeletePressed NameError: global name 'objParent' is not defined Here the code that, I think, solves the issue: def DeletePressed(self, root, userdata): "Called when a delete event is received." for tex in reversed(list(TextureObjectIterator(self.listOfTexture))): if tex.IsSelected: objParent = tex.GetParent() # Added listToRemove = objParent.GetChildren() if objParent is not None else self.listOfTexture listToRemove.remove(tex)
  • 0 Votes
    10 Posts
    1k Views
    B
    @m_magalhaes RE: Does using the object list iterator is mandatory or not ? For this one, it kinda is since the whole code base rest on the for loop section. RE: you can see in this file that i can use UserData Thanks for the clarification. I see what you mean now. It works on my use case. Have a great day ahead!