[Closed] ResetXForm of a Group?
Is i even possible to resetXForm of a group’s head? Rotated group.
The Group is rotated.
When I run this:
ResetXform $Group001
the group orientation in the scene is chaned.
$Group001.rotation
returns (quat 0 0 0 1)
.
but the selection brackets does not match the world axes(they not looks the same as when a geometry objects is resetXForm-ed).
The only solution that I can use is to ungroup the group and then to group all objects(and nested groups) again. But with nested groups the things become nasty.
The only difference that I can see is that the selection brackets are not aligned to the world XYZ axes. The pivot is oriented the same way in both cases: ResetXform and Reset Transform
It’s not the same, try it more than 1 time…
You can’t even do it in UI with groups (apply XForm modifier with Reset Xform utility)
The Reset XForm utility and the XForm modifier does nothing to a group, but
ResetXform $Group001
applied to the group’s head transforms the group and resets the rotation to 0,0 on all axes and the scale to 100% on all axes. The problem is that this code not works the same way as when it is applied to a mesh object.
here is a ‘pseudo’ code what you have to do (names of methods tell for themselves):
fn resetGroupHead head =
(
if (isgrouphead head) do
(
setgrouphead head off
cc = detachchildnodes head
resetnodexform head
attachchildnodes head cc
setgrouphead head on
head.transform
)
)
PS. with my mxs extension it’s the real code
PPS.
resetnodexform head
you can replace this line with setting a group head node transform what you want
Thank you. In your code setgrouphead head on
have to be before the attachchildnodes head cc
.
For now I use this code, whcih replaces every head of a group with new one. You will recognise your functions.
(
function IsGroupHeadMember head node act:off =
(
while isvalidnode node and isgroupmember node and not (act = (node.parent == head)) do node = node.parent
act
)
function GetAllGroupMembers head = if isgrouphead head do
(
for node in (join #() head) where IsGroupHeadMember head node collect node
)
grpH = $TopGroupHead
grpHName = grpH.name
allGrpChidArr = GetAllGroupMembers grpH
nestedGroupHeadsArr = for o in allGrpChidArr where (isGroupHead o or isOpenGroupHead o) collect o
setGroupOpen grpH true
if nestedGroupHeadsArr.count != 0 do
(
for nGh in nestedGroupHeadsArr do setGroupOpen nGh true
newGroupsArr = #()
for n = nestedGroupHeadsArr.count to 1 by -1 do
(
nGh = nestedGroupHeadsArr[n]
nGhParent = nGh.parent
nGhName = nGh.name
grpMembersArr = join #() nGh.children
grpHeadsArr = for o in grpMembersArr where isGroupHead o collect o
if grpMembersArr.count != 0 do
(
detachNodesFromGroup grpMembersArr
newG = group grpMembersArr name:nGhName
attachNodesToGroup newG nGhParent
setGroupOpen newG true
append newGroupsArr newG
)
)
if newGroupsArr.count != 0 do
(
for nGh in newGroupsArr do setGroupOpen nGh true
)
)
grpMembersArr = join #() grpH.children
newG = undefined
if grpMembersArr.count != 0 do
(
setGroupOpen grpH true
detachNodesFromGroup grpMembersArr
newG = group grpMembersArr name:(grpHName + "_new")
)
setGroupOpen newG false
)
For some reason, after this code is executed, I can select single objects from the nested groups, despite all group are closed.
You are right to not agree, because you are right. The fault was in my test scene. With new test scene everything works as you described.