Target Tag not fixing to target
-
Hi all,
We recently moved from Cinema R19 to R21 and manage to do the changes to our libraries.
One of the things I noticed is that when creating a target tag for a cameracam.MakeTag(c4d.Ttargetexpression)
does not work correctly when assigning a target, as the camera just moves and jumps around the viewport.
Added screen share below of a camera with added scripted target tag and a camera with added manual target tag.Am I missing something really obvious with the change between Cinema versions, please?
Thank you all in advance,
Andre
-
The video looks normal, the camera is targeting the cube. But it's hard to tell, as the quality is very low.
I didn't see the camera jump around. What did you expect to happen? -
@fwilleke80 Hi Frank,
Yes, apologies for the low-quality video. Think Google Drive may be compressing it somehow.
Not sure if you noticed, but on the Camera named Script_Target_Tag, I can pan in the viewport and the aim moves with it. Once I click anywhere it jumps back to the targeted Null/Cube.
While when added the target tag manually, it's always aimed at the targeted Null/Cube.Hope this makes sense.
Let me know if not and will do another comparison video.
Thank you in advance,
Andre
-
I would expect that MakeTag creates the same tag data as creating the tag from the menu. So I just tried, and...
...surprisingly, that is not the case. In the manually created tag, the flag "Camera Dependent" is checked. In the one created by script (with no further data set), this flag is unchecked.
This indeed leads to an effect as you described. If I set the flag in the script-created tag, it behaves just like the menu one. So I guess you just need to set the flag after creating the tag.
-
Hello @andreanjos,
thank you for reaching out to us. Your video is fine, one has only to increase the resolution since Google Drive always starts streaming with a low resolution. The behavior shown in your video is indeed odd, but the problem with the video is that you never show the attribute manager for target expression tag which sits on the camera
Script_Target_Tag
. And therefore also not if that expression has something linked in its target parameter. Given your results, I would assume that this is not the case.I just tried it in R21, and a programmatically created target expression works fine for me. For details, please see the screencast and script at the end. If the problem persists, I will have to ask you to share code and scene files. So that we can understand better what you are doing.
Cheers,
FerdinandMy results (click the image to enlarge it):
Very simple script to create a targeted camera for the selected object:
import c4d def main(): """Creates a camera with a target expression linking the currently selected object. """ if not isinstance(op, c4d.BaseObject): raise ArgumentError("Please select an object.") # Create a camera object and insert it into the document. camera = c4d.BaseList2D(c4d.Ocamera) camera.SetMg(c4d.Matrix(off=c4d.Vector(300, 0, 0))) doc.InsertObject(camera) # Add the target tag to the camera and link the object. tag = camera.MakeTag(c4d.Ttargetexpression) tag[c4d.TARGETEXPRESSIONTAG_LINK] = op c4d.EventAdd() # Execute main() if __name__=='__main__': main()
-
Hi @Cairyn and @ferdinand
Many thanks for your input.
It definitely works if you enable the Camera Dependent flag as Cairyn mentioned.
I'm just trying to figure out how to enable it.tag[c4d.EXPRESSION_PRIORITY].SetPriorityValue(c4d.PRIORITYVALUE_CAMERADEPENDENT, True)
perhaps?
This is not working, so not sure if I should do it via SetParameter.@ferdinand Cheers for your screenshare and code. Unfortunately, it still happens with your code. If you look through the camera and pan around does the target stays fixed for you?
P.S. What do you use for your screen share gifs, please?
Thank you both!
-
That line will return a copy of the PriorityData, not a reference, so after changing it, you need to write it back explicitly.
newTag = cam.MakeTag(c4d.Ttargetexpression) if newTag == None: return pd = newTag[c4d.EXPRESSION_PRIORITY] pd.SetPriorityValue(c4d.PRIORITYVALUE_CAMERADEPENDENT, True) newTag[c4d.EXPRESSION_PRIORITY] = pd c4d.EventAdd()
-