Limit the doc.SearchObject() on the source document?
-
Hi,
On my character rig, I have a line like this:
hips_con = doc.SearchObject('hips_con)
It works on the source document but once I reference the file it doesn't work since the file will now have a name of
character_name::hips_con
I can't delete the namespace entirely since there will be several character that have the same rig set-up in a single scene.
So, is there a way to limit the doc.SearchObject() on the source document and not on the reference document?Thank you for looking at the problem.
-
Hi @bentraje could you be more specific or link a scene file example.
You say namespace, but so far only Xref used namespace. You also talk about referencing the file which makes me thinking of an Xref.
But since you speak about the character object, which also uses some kind of virtual document.
I'm not sure.Cheers,
Maxime. -
Hi @m_adam
Thanks for the response.
Sorry for the confusion.
Yes, I am talking with the Xref object when I mentioned "referenced file"
and No, I'm not talking about character object. I just mentioned character. As in my character in general.Please see the illustration file below:
https://www.dropbox.com/s/c5297hvjspal63i/c4d108_localized_python_command.rar?dl=0In the source file, it prints the BaseObject since it found the object
In the reference file, it should print also the BaseObject but it finds none because of the namespace.That is why I am looking to limit the doc.SearchObject function on the source document and not on the file it is referenced.
Is there a way around this?
Thank you.
-
Hi @bentraje, you actually have to handle it yourself.
Here is an exampleimport c4d def main(): nameToSearch = "Cube" # Retrieves the parent object of the host object parent = op.GetObject().GetUp() xref = None # Iterates overs each parent while parent: # if it's an xref, break and store it if parent.CheckType(1025766): xref = parent break parent = parent.GetUp() # If an xref is defined then retrieve the namespace if xref is not None: namespace = xref[c4d.ID_CA_XREF_NAMESPACE] nameToSearch = namespace + "::" + nameToSearch # Search the object Cube = doc.SearchObject(nameToSearch) print Cube
Remember if you simply want to access the host object you can call BaseTag.GetObject from the python tag.
If you have any question, please let me know.
Cheers,
Maxime. -
I have a handful of
doc.SearchObject()
so I was looking for an easier route.
I guess there is no way around it except concatenating strings.Anyhow, thanks for the code and confirmation.
Will tag this thread as closed.
Have a great day ahead!