help with last similar operation in stack

kowy
Posts: 47
Joined: 01 Jun 2020, 16:30

Re: help with last similar operation in stack

Post by kowy » 17 Oct 2021, 20:18

Can u help with another script ?
Mirror on X with Transforms-> just scaling to -1 won't preserve transforms, needs some extra - my attempt is SetExpression
where it's usefull -> to transform multiple objects to preserve scaling -1 I have to go to edit mode, select all and apply a transform, ok for low poly count, when model comes from zbrush or other heavy objects - selecting all takes some time
unsolved
1. multiple selection (now works only on 1 object)
2. I'm not sure about set expression - > a. after running script pops-up setexperssion ppg, b. script runs slow, c. after closing set exp editor pops up an error

Code: Select all

ResetTransform(null, siCtr, siSRT, siXYZ);
var sel = Selection(0);
var c = Clone(null, null, 1, 1, 0, 0, 1, 0, 1, null, null, null, null, null, null, null, null, null, null);
Scale(null, -1, 1, 1, siAbsolute, siPivotCOG, siObj, siX, null, null, null, null, null, null, null, 0, null);

//position
AddExpr(c + ".kine.local.posx", "", null);
SetExpr(c + ".kine.local.posx", "-"+sel + ".kine.local.posx", null);

AddExpr(c + ".kine.local.posy", "", null);
SetExpr(c + ".kine.local.posy", sel + ".kine.local.posy", null);

AddExpr(c + ".kine.local.posz", "", null);
SetExpr(c + ".kine.local.posz", sel + ".kine.local.posz ", null);

//rotation
AddExpr(c + ".kine.global.rotx", "", null);
SetExpr(c + ".kine.global.rotx", sel + ".kine.global.rotx", null);

AddExpr(c + ".kine.global.roty", "", null);
SetExpr(c + ".kine.global.roty", "-"+sel + ".kine.global.roty", null);

AddExpr(c + ".kine.global.rotz", "", null);
SetExpr(c + ".kine.global.rotz", "-"+ sel + ".kine.global.rotz ", null);

//scale
AddExpr(c + ".kine.local.sclx", "", null);
SetExpr(c + ".kine.local.sclx", "-"+ sel + ".kine.local.sclx", null);

AddExpr(c + ".kine.local.scly", "", null);
SetExpr(c + ".kine.local.scly", sel + ".kine.local.scly", null);

AddExpr(c + ".kine.local.sclz", "", null);
SetExpr(c + ".kine.local.sclz", sel + ".kine.local.sclz ", null); 
 
MoveCtr2Vertices(sel, true);
SelectObj(sel, null, true);

User avatar
Kolya
Posts: 39
Joined: 03 Oct 2017, 19:17

Re: help with last similar operation in stack

Post by Kolya » 18 Oct 2021, 13:10

Hi, place .xsicompound into C:\Users\user_name\Autodesk\Softimage_version\Data\Compounds and restart Softimage

Code: Select all

var s = new ActiveXObject( "XSI.Collection" );
s.AddItems(Selection);

var c = Clone(s);
for(var i=0, sCount=s.Count; i<sCount; i++){
	var op = SIApplyICEOp("MirrorConstraint", c(i),  s(i));
}
Attachments
MirrorConstraint.xsicompound
(15.55 KiB) Downloaded 159 times
Last edited by Kolya on 18 Oct 2021, 15:20, edited 1 time in total.

kowy
Posts: 47
Joined: 01 Jun 2020, 16:30

Re: help with last similar operation in stack

Post by kowy » 18 Oct 2021, 14:36

I'm new to this stuff, needs some explanations
i'm getting an error

// ERROR : 21000-EDIT-SIApplyICEOp - Unspecified failure
SIApplyICEOp("MirrorConstraint", "cube1", null, siUnspecified, null);
// ERROR : - [line 6]

place .xsicompound -> should be black ? *.xsicompound or should be MirrorConstraint.xsicompound ?
can't find MirrorConstraint on google
inline icetree searching for MirrorConstraint 0 results
explorer searching for MirrorConstraint 0 results

User avatar
Kolya
Posts: 39
Joined: 03 Oct 2017, 19:17

Re: help with last similar operation in stack

Post by Kolya » 18 Oct 2021, 15:26

I'm sorry I thought I added to MirrorConstraint.xsicompound to Attachments, now I did.

kowy
Posts: 47
Joined: 01 Jun 2020, 16:30

Re: help with last similar operation in stack

Post by kowy » 18 Oct 2021, 16:38

Thanks !

kowy
Posts: 47
Joined: 01 Jun 2020, 16:30

Re: help with last similar operation in stack

Post by kowy » 19 Oct 2021, 23:39

are any ways to ivoke assign material or draw curve & other commands that react(script editor) only after doing first step ?

User avatar
Kolya
Posts: 39
Joined: 03 Oct 2017, 19:17

Re: help with last similar operation in stack

Post by Kolya » 20 Oct 2021, 10:58

I don't quite understand the question.
You can assign material using SIAssignMaterial(Object, Materiel)
Do you mean draw curve tool? then it's CVNURBSCurveTool(), NURBSCurveTool(), BezierCurveTool(), LinearCurveTool(), SketchCurveTool()

kowy
Posts: 47
Joined: 01 Jun 2020, 16:30

Re: help with last similar operation in stack

Post by kowy » 20 Oct 2021, 13:07

for curves I didn't know
as for materials
selecting objects and for picking i need to select second object
what will be the command to ivoke picking second object(for assigning to first selection second's material) ?

User avatar
Kolya
Posts: 39
Joined: 03 Oct 2017, 19:17

Re: help with last similar operation in stack

Post by Kolya » 20 Oct 2021, 14:15

Code: Select all

var sel = Selection;
var sCount = sel.Count;
if(sCount > 0){
	var pickObj = PickObject("Object");
	if(pickObj(0) !== 0){
		var pObjMat = pickObj(2).Material;
		for(var i=0; i<sCount; i++){
			SIAssignMaterial(sel(i), pObjMat);
		}
	}
}

kowy
Posts: 47
Joined: 01 Jun 2020, 16:30

Re: help with last similar operation in stack

Post by kowy » 20 Oct 2021, 16:55

perfect ! works with clusters too !!!

kowy
Posts: 47
Joined: 01 Jun 2020, 16:30

Re: help with last similar operation in stack

Post by kowy » 27 Oct 2021, 22:20

if u can help with smt else
1. mouse4/5 binding commands
2. script for toogle
* increase subd *2+, highlightwireframe opacity 0,
* decreasesubd *2, highlightwireframe opacity 1,

User avatar
Kolya
Posts: 39
Joined: 03 Oct 2017, 19:17

Re: help with last similar operation in stack

Post by Kolya » 28 Oct 2021, 10:26

1. I think you can bind a command on a keyboard shortcut in XSI then using something like AutoHotkey make it press that key when you press 4/5 mouse button, but I can't tell how exactly I haven't worked with it.
2. Toggle subdiv and wireframe opacity

Code: Select all

var cam = GetViewCamera();
var prp = cam.Properties("Camera Display").Parameters("wireframeopacity");
var wo = prp.Value;

if(wo == 1)prp.Value = 0;
else prp.Value = 1;

var objs = new ActiveXObject("XSI.Collection");
objs.Items = ".[obj].";
for(var i=0, c=objs.Count; i<c; i++){
	var obj = objs(i);
	if(obj.Type == "polymsh"){
		SIMakeLocal(obj.Properties("Geometry Approximation"));
		var ga = obj.Properties("Geometry Approximation");
		var vr = ga.Parameters("gapproxmosl");
		var rr = ga.Parameters("gapproxmordrsl");
		if(wo == 1){
			vr.Value = 2;
			rr.Value = 2;
		}else{
			vr.Value = 0;
			rr.Value = 0;
		}
	}
}

kowy
Posts: 47
Joined: 01 Jun 2020, 16:30

Re: help with last similar operation in stack

Post by kowy » 28 Oct 2021, 22:28

thanks !
AutoHotkey also works !

kowy
Posts: 47
Joined: 01 Jun 2020, 16:30

Re: help with last similar operation in stack

Post by kowy » 02 Nov 2021, 14:31

ohayo !
if u can help me again, 3 scritps
1. toogle between global + cog -> local
2. toogle between pick reference plane + reference plane mode -> pick reference plane + reference plane mode + cog (pick reference plane by default is "ctrl -")
3. SplitEdge Loop, found one but with continuity -> AddSmoothEdgeLoopTool
& a question if it's possible to imbed into spld extra buttons for scripts (aka bevel with paneling options)

User avatar
Kolya
Posts: 39
Joined: 03 Oct 2017, 19:17

Re: help with last similar operation in stack

Post by Kolya » 02 Nov 2021, 17:33

Hello!
1.

Code: Select all

var refMode = GetUserPref("3D_TRANSFO_REFERENTIAL_CHANGED")
if(refMode == 2)
	SetUserPref("3D_TRANSFO_REFERENTIAL_CHANGED", 17);//global(1) + cog(16)
else
	SetUserPref("3D_TRANSFO_REFERENTIAL_CHANGED", 2);//local(2)
2. Sorry I don't really get it, can you please explain it better

3. If you mean Split Edge Tool then it's SplitEdgeTool();

4. You can add a button insde of a Layout like this

Code: Select all

Button myButton = "Button text";
then in Logic add

Code: Select all

Sub myButton_OnClicked()
'your code
End Sub

kowy
Posts: 47
Joined: 01 Jun 2020, 16:30

Re: help with last similar operation in stack

Post by kowy » 03 Nov 2021, 11:36

1. thanks
2. for Ref there are 2 options
a. right click and pick a polygon/edge/object/point and other options
b. if i have something preselected, I could press "ctrl + -" to make reference plane from that selection
i''m looking towards b
and toggle should be ~ make reference plane from selected + switch mode to ref -> make reference plane from selected + switch mode to ref+ cog
3. SplitEdgeTool() just middle button (split loop) -> towards AutoHotkey -using often
4. will try

Post Reply

Who is online

Users browsing this forum: No registered users and 35 guests