Hello @JH23,
first, I would like to point out that we ask the community here to post separate questions into separate postings, so that other users can find more easily answers when searching the forum. You can read more about the procedures of SDK support in our Forum Guidelines. It is okay in this case, but for future cases we have to ask you to open new topics for follow-up questions that are not directly related to the initial question of the topic (thread).
About your question - you have two options when you want to make an object editable:
In case you already have the object in question already inserted into the active document and are in the main thread, you can still use CallCommand. For CallCommand you have to keep in mind that it usually relies on an object selection. When running it in a script, you have then make sure that actually the objects you want to be affected are selected when you do run the CallCommand. I have provided an extension of my prior example at the end of this posting.
In all other cases, i.e., when the object is either in no document or not in the active one, or you are not on the main thread, then you must use c4d.utils.SendModelingCommand
Link. In this case for example for the command MCOMMAND_MAKEEDITABLE. You can find more information about that in our SDK documentation and in the
code examples on GitHub.
Cheers,
Ferdinand
Example code:
import c4d
def main():
# Assuming you want to use a CallCommand, you can do this. In practice
# instantiating a cube object is better done in the way shown by Cairyn
# in the forums.
# The CallCommand for creating a cube object which will also insert and
# select the cube.
c4d.CallCommand(5159)
# Get the currently active object; which is the new cube object due to the
# prior CallCommand. The function object() created by the script log, and
# used in your code, does effectively something similar. But it has the
# overhead of retrieving the active object each time it is being called,
# which is not necessary here.
# In a script environment there are also the predefined attributes op and
# doc, "variables" in non-Python terms. op is the currently active object
# when the script is being run and doc the currently active document.
# We cannot use op here, since the CallCommand just did change that, but
# we can use doc, which we could retrieve also manually if we had to via
# c4d.documents.GetActiveDocument().
cube = doc.GetActiveObject()
# Set some of the parameters of that cube object.
cube[c4d.ID_BASELIST_NAME] = "Cube"
cube[c4d.PRIM_CUBE_LEN, c4d.VECTOR_X] = 32
cube[c4d.PRIM_CUBE_LEN, c4d.VECTOR_Y] = 32
cube[c4d.PRIM_CUBE_LEN, c4d.VECTOR_Z] = 32
cube[c4d.PRIM_CUBE_SUBX] = 11
cube[c4d.PRIM_CUBE_SUBY] = 11
cube[c4d.PRIM_CUBE_SUBZ] = 11
# Instantiate manually a cone object and insert it under that cube, i.e.,
# do it like Cairyn has shown it.
cone = c4d.BaseObject(c4d.Ocone)
# We can also set the name of a node like this, which is a bit easier to
# remember than the ID.
cone.SetName("Cone")
# Set some parameters of the cone. You can find out parameter ids via
# drag and drop and the console, read more about it here:
# developers.maxon.net/docs/Cinema4DPythonSDK/html/misc/descriptions.html
cone[c4d.PRIM_CONE_HEIGHT] = 32
cone[c4d.PRIM_CONE_BRAD] = 16
cone[c4d.ID_BASEOBJECT_REL_POSITION, c4d.VECTOR_Y] = 32
# Create a phong tag for the cone, so that the cone is being shaded nicely.
phongTag = cone.MakeTag(c4d.Tphong)
# Enable the angle limit of the phong tag.
phongTag[c4d.PHONGTAG_PHONG_ANGLELIMIT] = True
# Insert the cone under the cube.
cone.InsertUnder(cube)
# When we are doing things "manually", i.e., do not use CallCommand, we
# have to push an update to Cinema 4D after we have modified the scene
# graph.
c4d.EventAdd()
# Make the cube object the new active selection.
doc.SetActiveObject(cube, c4d.SELECTION_NEW)
# And run the " Make Editable" CallCommand on that
c4d.CallCommand(12236) # Make Editable
if __name__ == '__main__':
main()