Oh gotcha. Thanks for the reminder. Totally forgot they UNDOTYPE_CHANGE
have a different placement thant UNDOTYPE_NEW
Thanks again. Have a great day ahead!
Oh gotcha. Thanks for the reminder. Totally forgot they UNDOTYPE_CHANGE
have a different placement thant UNDOTYPE_NEW
Thanks again. Have a great day ahead!
Hi,
In this thread, it offers the solution to use the doc.ExecutePasses
to "bake" the effect of the PSR when the PSR tag is deleted. My problem is when I inserted the doc.AddUndo(), it does not work (i.e. the object does not move back the original position).
You can see an illustration of the problem here:
https://www.dropbox.com/s/c5b3g1f5dr0el7z/c4d183_addundo_with_doc_execute_passes.mp4?dl=0
As you can see, only the tag creation is undone but not the movement of the object.
Is there a way around this? Thank you for looking at my problem
You can see the working code here:
import c4d
from c4d import gui
# Select two objects then execute
def create_constraint():
doc = c4d.documents.GetActiveDocument()
obj_sel = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_SELECTIONORDER)
driven = obj_sel[-1]
driver = obj_sel[0]
doc.StartUndo()
tag = c4d.BaseTag(1019364)
driven.InsertTag(tag)
doc.AddUndo(c4d.UNDOTYPE_NEW, tag)
tag[c4d.ID_CA_CONSTRAINT_TAG_PSR] = True
tag[c4d.ID_CA_CONSTRAINT_TAG_PSR_MAINTAIN] = False
tag[10001] = driver
doc.ExecutePasses(None, True, True, True, c4d.BUILDFLAGS_0)
doc.AddUndo(c4d.UNDOTYPE_CHANGE, driven)
doc.EndUndo()
c4d.EventAdd()
if __name__=='__main__':
create_constraint()
Hi @r_gigante
Thanks for the confirmation. Hopefully, it will be possible in the near future.
Have a great day ahead!
Hi,
In the newest update R21.1, Redshift is now supported in the built-in node editor.
My main concern is can I now script creation of the redshift node materials?
I checked the API reference, but I couldn't find any resources. Can someone confirm?
Thank you.
@Cairyn and @r_gigante
Apologies for the late response.
Yes, the ExecutePasses
works as expected. Thanks for the solution.
I can't use the SetMg()/GetMg()
because the script is part of a larger base code which is not limited only to the PSR tag.
Thanks again. Have a great day ahead!
Hi.
You can see an illustration of the problem here:
https://www.dropbox.com/s/e9w1ifjrj2mxbhe/c4d180_remove_method_negates.mp4?dl=0
Without the .Remove() method, the script works as expected (i.e. the sphere snaps to the circle).
When I add the .Remove Method. It no longer works. (i.e. the sphere no longer snaps to the circle)
You can check the working code here:
import c4d
from c4d import gui
def create_constraint(mo=False):
obj_sel = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_SELECTIONORDER)
driven = obj_sel[-1]
driver = obj_sel[0]
tag = c4d.BaseTag(1019364)
driven.InsertTag(tag)
tag[c4d.ID_CA_CONSTRAINT_TAG_PSR] = True
if mo == True:
tag[c4d.ID_CA_CONSTRAINT_TAG_PSR_MAINTAIN] = True
else:
tag[c4d.ID_CA_CONSTRAINT_TAG_PSR_MAINTAIN] = False
tag[10001] = driver
tag.Remove()
c4d.EventAdd()
if __name__=='__main__':
create_constraint()
Thank you for looking at my problem
Hi,
In the c4d.gui.ShowPopupDialog documentation. It offers menu.InsData(c4d.Ocube, "CMD")
to add a cube. It works.
I tried modifying it to menu.InsData(c4d.Tphong, "CMD")
but the phong icon does not appear like the cube icon above.
Does this mean the menu.InsData
referred in the documentation works only on objects and not tags?
Thank you for looking at my problem
@s_bach
Thanks for the response! Works as expected.
@zipit
No worries. Will close this thread.
I will probably revive this a year from now (lol). I have a feeling that Matrix will haunt me again in other aspects so this would be a nice exercise if that happens.
Thanks again!
Uhm, yep. For the pivot, I guess I'm also interested on the its "tiltedness". Basically, what the coordinate manager shows (the position and rotation). Sorry for not being clear.
I would just really like to call on the GetModelingAxis
since it corresponds exactly with the coordinate manager but it only works on a selected object not document per se. In other words, it works only on one object but not on multiple objects.
RE: I do not have the time to do it right now
No worries. Thanks for the response. Have a great day ahead! :)
Hi @zipit
Thanks again for the response.
RE: this thread might help you out
Yes, I'm trying to reperform the Axis Center
manager but through code. However, unlike in the thread you referred to where the axis is arbitrary, I wanted the bottom center pivot. (Or Bottom Center Axis? In Maya, it's called a Pivot)
RE: Pseudo Code
I'm assuming the aforementioned code is in bottom world space (i.e. the bottom center world space and the bottom center local space is a different solution). Correct me if I'm wrong.
Your code works for world space other than 0. But not if its in 0. See illustration here:
https://www.dropbox.com/s/4rk3cdu83wydnn8/c4d178_python_get_bottom_center_pivot02.jpg?dl=0
RE: _p.y
Just wondering where is the .y
referred? I can't see it in the documentation. The only way I would be able to retrieve it previously is through GetMg().off[1]