if(Node.SubObjectCount('/D3DView')==0) return;
var sel = Node.Selection();if(!sel){return;};
var selCount = Node.SelectedCount();
if(selCount > 1) {
System.Alert("Select one object at a time")
return
}
if(Node.ConExists(Node.FirstSelected(), "Target Matrix"))
{
System.Alert("Object is being used to Look At another object\n\nUse the Unlook At tool first");
return;
}else{
RsTool.NormalizeRotation('');
ToolMng.ActivateTool('{17D544A3-3F58-436B-83E7-F8B4D7D4E7C5}','{4E203C6C-A20D-4e32-82B4-FC482F5A0D06}');
}
if(Node.SubObjectCount('/D3DView')==0) return;
var sel = Node.Selection();if(!sel){return;};
var selCount = Node.SelectedCount();
if(selCount > 1) {
System.Alert("Select one object at a time")
return
}
if(Node.ConExists(Node.FirstSelected(), "Target Matrix"))
{
System.Alert("Object is being used to Look At another object\n\nUse the Unlook At tool first");
return;
}else{
RsTool.NormalizeRotation('');
ToolMng.ActivateTool('{17D544A3-3F58-436B-83E7-F8B4D7D4E7C5}','{4E203C6C-A20D-4e32-82B4-FC482F5A0D06}');
}
Looks good to me. You don't need the else when using a return
if(Node.SubObjectCount('/D3DView')==0) return;
var sel = Node.Selection();if(!sel){return;};
var selCount = Node.SelectedCount();
if(selCount > 1) {
System.Alert("Select one object at a time")
return
}
if(Node.ConExists(Node.FirstSelected(), "Target Matrix"))
{
System.Alert("Object is being used to Look At another object\n\nUse the Unlook At tool first");
return;
}
RsTool.NormalizeRotation('');
ToolMng.ActivateTool('{17D544A3-3F58-436B-83E7-F8B4D7D4E7C5}','{4E203C6C-A20D-4e32-82B4-FC482F5A0D06}');
trueBlue wrote: ↑23 Aug 2022, 15:54
It looks like RsTool.NormalizeRotation(''); is only needed for Lights
How would you write that?
It doesn't matter since the rotations are taken over by the lookat anyway.
Yeah, but it is kind of funky normalizing the rotation on everything before the Look At command is ran and it is only for Model Lights
I would go even further, isolating the Workspace Lights by looking for the "Intensity" connector
if(Node.SubObjectCount('/D3DView')==0) return;
var sel = Node.Selection();
var selCount = Node.SelectedCount();
var fsel = Node.FirstSelected();
if(!sel){return;}
if(selCount > 1) { System.Alert('Select one object at a time');return;}
if(Node.ConExists(fsel, 'Target Matrix')) { System.Alert('Object is being used to Look At another object\n\nUse the Unlook At tool first');return;}
if(Node.IsLight(fsel) && !Node.ConExists(fsel, 'Intensity')) { RsTool.NormalizeRotation(fsel);}
ToolMng.ActivateTool('{17D544A3-3F58-436B-83E7-F8B4D7D4E7C5}','{4E203C6C-A20D-4e32-82B4-FC482F5A0D06}');
trueBlue wrote: ↑23 Aug 2022, 15:54
It looks like RsTool.NormalizeRotation(''); is only needed for Lights
How would you write that?
It doesn't matter since the rotations are taken over by the lookat anyway.
Yeah, but it is kind of funky normalizing the rotation on everything before the Look At command is ran and it is only for Model Lights
I would go even further, isolating the Workspace Lights by looking for the "Intensity" connector
if(Node.SubObjectCount('/D3DView')==0) return;
var sel = Node.Selection();
var selCount = Node.SelectedCount();
var fsel = Node.FirstSelected();
if(!sel){return;}
if(selCount > 1) { System.Alert('Select one object at a time');return;}
if(Node.ConExists(fsel, 'Target Matrix')) { System.Alert('Object is being used to Look At another object\n\nUse the Unlook At tool first');return;}
if(Node.IsLight(fsel) && !Node.ConExists(fsel, 'Intensity')) { RsTool.NormalizeRotation(fsel);}
ToolMng.ActivateTool('{17D544A3-3F58-436B-83E7-F8B4D7D4E7C5}','{4E203C6C-A20D-4e32-82B4-FC482F5A0D06}');
I tried a model infinite light and it didn't have the problem, so you'll want to check the model light types to see which ones need the normalize rotation.
trueBlue wrote: ↑23 Aug 2022, 17:11
What?
For me the Model Infinite light points in the opposite direction using Workspace's original Look At command
Model Infinte light used in Workspace's original Look At command.png
.
Have not tested any other Model lights yet
I'll double check, maybe I accidentally did a workspace light.
Yep, checks out.
new scene in model
lookat for infinite light is correct
trueBlue wrote: ↑23 Aug 2022, 17:11
What?
For me the Model Infinite light points in the opposite direction using Workspace's original Look At command
Model Infinte light used in Workspace's original Look At command.png
.
Have not tested any other Model lights yet
I'll double check, maybe I accidentally did a workspace light.
Yep, checks out.
new scene in model
lookat for infinite light is correct
Confirm you are correct in your example
Try adding a Model infinite light, switch to Workspace and run Look At
Model infinite light is in opposite direction
Then try Un Look At
Model infinite light is not restored correctly