Parametric modeling (Closed linear curves for start)

Plugins linking to this thread: (hide)

ICE Curve CreationAuthor: Pedro Cabrera
Pedro Cabrera a.k.a. Pedrito shares this plugin that allowing dynamic creation of curve objects using ICE. Unlike point cloud and polygon mesh creation, curve creation isn't supported natively by ICE. The author works around this by using a vbs scripted operator that reads data written by an ICE tree further down the operator stack.

From here: [..] it allows linear and cubic curves, open and closed, and also subcurves, so »create curves from strands« for example is as easy as plug a »build array from set« of the strandpositions, and a »build array from set« of the strand count [..] These compounds are also provided: PC_Archimedean Spirals: different types of spirals PC_Curve By Nulls: uses a group of transforms to create a curve PC_Loxodrome: creates a loxodrome spiral with parameters PC_Spiral Points: very basic Spiral

local backup:PC_IceCv.xsiaddon PC_ICeCV_sample.scn (sample scene)

Discussions regarding modelling with SOFTIMAGE©
User avatar
mc_axe
Posts: 415
Joined: 12 Mar 2013, 18:44

Parametric modeling (Closed linear curves for start)

Post by mc_axe » 26 Dec 2017, 00:10

Hello Guys, not long ago I came across a situation, were i had to 'solve' a 2d shape outside of SI on paper with my rusty trigonometric skills, and actually I had to do the same over and over again with different parameters, in order to extract info and pick 2-3 designs that suit my case, with targer to visualize later in SI. Because im nub with development i used Khan academy (processing JS) to make it parametric, helped me greatly but is still just a shape in my browser and some info. Question is: How i can do the same directly in Softimage, a closed linear curve would be a gr8 start. My ultimate goal ofcourse is to contribute with more geometry generator tools that inlcude even 3d geo (so SI never feels old), but id like to start from pretty basic stuff.

Just want to know the big picture. If anyone have a clue and can point me at a direction im all ears :)

User avatar
rray
Moderator
Posts: 1774
Joined: 26 Sep 2009, 15:51
Location: Bonn, Germany
Contact:

Re: Parametric modeling (Closed linear curves for start)

Post by rray » 26 Dec 2017, 00:46

Hi mc_axe, not sure but might this help? There's a few compounds inside the thread:

viewtopic.php?f=41&t=1942
softimage resources section updated Jan 5th 2024

User avatar
mc_axe
Posts: 415
Joined: 12 Mar 2013, 18:44

Re: Parametric modeling (Closed linear curves for start)

Post by mc_axe » 27 Dec 2017, 01:12

The link`d/thread is a beast of tutorial for ICE modeling :ymparty: bookmark`d, thank you rray!

Abt linear curves, i will try with JSscript direclty in SI script editor. My first chalenge is a str8 line :P

User avatar
rray
Moderator
Posts: 1774
Joined: 26 Sep 2009, 15:51
Location: Bonn, Germany
Contact:

Re: Parametric modeling (Closed linear curves for start)

Post by rray » 29 Dec 2017, 19:08

A single strand could be an option too, you get more direct feedback than with scripting.
softimage resources section updated Jan 5th 2024

User avatar
mc_axe
Posts: 415
Joined: 12 Mar 2013, 18:44

Re: Parametric modeling (Closed linear curves for start)

Post by mc_axe » 29 Dec 2017, 21:51

Hey rray also a nice suggestion i remeber that ice can print things on screen, but can i also have indirect info? Im trying this with JS and variables, but im still a nub that only watched half Khan academy lesson and i still trying to figure syntax etc, I did manage to scrpt a parametric linear curve (a line lol) and print with log , any suggestions for a good JScript reference?

Here is an imaginary example to let you understand the sort of challenges that i try to figure

Lets say tht we have an isosceles trapezoid:
Image
We define it by lets say height and length of horizontal lines, then we want to solve, and print varius angles that require even to add imaginary points to solve, ratios, distances, lengths, maybe even areas. It can get more and more complicated if we add more shapes, or even worst if this is just a part of a larger shape.

Another example:
Image
Lets say that im assigned to model a bridge for a short film, a second guy is creating a cargo ship a 3rd one conteigners. The ship conteignes very wide have to pass 5 cm from the truss and chimney 10 cm from the top of the arc. Now because proportions height of ship etc change every ten minutes i deside to create a script. When i do i can also focus on modeling and i can tell my team that the bridge looks horible if we exceed some ratios.

The whole point is to being able to play with values, have very accurate info at same time, and most imortantly being able to convert this to a real model later.

User avatar
rray
Moderator
Posts: 1774
Joined: 26 Sep 2009, 15:51
Location: Bonn, Germany
Contact:

Re: Parametric modeling (Closed linear curves for start)

Post by rray » 29 Dec 2017, 22:59

I see - tbh I would probably jump straight to Fusion 360 for that, it sounds exactly like what CAD programs were made for. You could make a 2D sketch, set constraints on angles, parallel lines, areas etc. and everything is solved "on the fly" while you're working or changing measurements. It's also free unless you're in a rather large company, but an issue is that it doesn't have too many export options so you might have to go through Maya to get uvs in Softimage.

Having a toolset like this as an addon to XSI would be very cool of course, but would probably be a lot of work.
softimage resources section updated Jan 5th 2024

User avatar
mc_axe
Posts: 415
Joined: 12 Mar 2013, 18:44

Re: Parametric modeling (Closed linear curves for start)

Post by mc_axe » 30 Dec 2017, 17:01

Is good to know that i have all these alternatives. For now i will try to play with simple shapes in Softimage. We also have some measuring tools avail can help some times.
An addon like (constraints etc) would be awesome, but since is too much of a work maybe it could be done in pieces.

User avatar
mc_axe
Posts: 415
Joined: 12 Mar 2013, 18:44

Re: Parametric modeling (Closed linear curves for start)

Post by mc_axe » 30 Dec 2017, 18:20

OKay lets start with super basic stuff for example:

The Str8 Line Challenge :-o

Image
SICreateCurve creates an empty curve
SICreateCurve( [Name], [Degree], [CurveType] )
To add points in the curve we can use SIAddPointOnCurveAtEnd .
SIAddPointOnCurveAtEnd( InputObj, [X], [Y], [Z], [Local], [CurveType], [PreserveTrace] )


However if we try to generate a curve with alot of points (added one after the other with 1 command per point) it takes too much time.
To generate them with just one command we can use instead :
SISetCurvePoints
SISetCurvePoints( InputObj, [Points], [Local] )
Following script generates a curve that is actually a str8 line of lenght 1000 with 1001 points.

Code: Select all

var pointslist = "(0,0,0)";
	for (i=1; i<=1000; i++){
	pointslist+=",("+i+",0,0)";
	}
LogMessage(pointslist);

crv=SICreateCurve("Linear_Curve_Line", 1, 1);
SISetCurvePoints( crv, pointslist, false );
So whatr we did here: We added all the point positions in a string variable (we put them in a package) with a for loop and then we just send it to the "factory"
Log message let us monitor things (which is nice), in that case it prints the entire string.

We can alter the script easily to receive for example the total Length of the line in a variable, we can introduce steps, and we could print the lenght of each section.
We can even start adding conditions for example add point only if the number is a prime number, or create other sequencing more interesting from a modeling persp.

Comming next a circle? a square!? Who knows!
Last edited by mc_axe on 07 Jan 2018, 19:50, edited 1 time in total.

User avatar
FXDude
Posts: 1129
Joined: 19 Jun 2012, 21:59

Re: Parametric modeling (Closed linear curves for start)

Post by FXDude » 31 Dec 2017, 22:57

Hi!

Perhaps this could also be of help? ::
http://andy.moonbase.net/archives/940

Which can also be applied to strands and then (parametrically live) curves (with Strands to Curves)

User avatar
mc_axe
Posts: 415
Joined: 12 Mar 2013, 18:44

Re: Parametric modeling (Closed linear curves for start)

Post by mc_axe » 01 Jan 2018, 23:15

FXDude wrote: 31 Dec 2017, 22:57 Hi!

Perhaps this could also be of help? ::
http://andy.moonbase.net/archives/940

Which can also be applied to strands and then (parametrically live) curves (with Strands to Curves)
Hey FXDude, not expert on ICE or strands here but actually anything could help and it looks promising thanx! Even if its not a solution that converts Softimage magically to a full CAD programm, it could help to create some strand / curve primitive generators, the live part sounds interesting and on screen info is nice as well. As rray said im not sure if i can set all those fancy CAD-ish contraints, to define my shape, or have that 'evrything is solved on the fly functionality', Ill have to try and see its limitations.

So far scripting looks promising, it misssing UI (cause im nub) and i might have to solve my shape depending on what is given and not. And if i want more that 2 definitions i need to start adding IFs.
So for complicated stuff i might just write targeted scripts that solve one case / monitor the info that i want on log.
Is also fun way to learn basic JS, will definatelly try out ICE later! Cheers

User avatar
mc_axe
Posts: 415
Joined: 12 Mar 2013, 18:44

Re: Parametric modeling (Closed linear curves for start)

Post by mc_axe » 01 Jan 2018, 23:53

The square challenge!
Image

Here my horrible (i bet) code for a Linear curve square, im still using the string to populate my points / draw the curve at the end.
The plan was simple change direction every quarter. Then it got a litl more complicated with divisions.

Code: Select all

//Linear Curves Parametric Square V0.12

var SqSL=4;	//Side Lenght 
var div=4;	//Divisions (Sections per Side)

///// Calcs
var sL=SqSL/div;//Section lenght.
var h=SqSL/2; //half side
var tip=[-h,-h]; //tip of our "pen" starting possition
var Area=Math.pow(SqSL,2); //Area
var Hypo=Math.sqrt(2*Area); //Hypotenuse 

var pointslist=""; //point positions for curve (string)


if(div>0){ 

		for(i=1; i<=4; i++){
	
			if (i===1){				
				for(j=1; j<=div; j++){
				pointslist+="("+tip[0]+","+tip[1]+",0),";
				tip[0]+=sL;
				}		
			}
				
			if (i===2){ 
				for(k=1; k<=div; k++){ 
				pointslist+="("+tip[0]+","+tip[1]+",0),";
				tip[1]+=sL;
				}		
			}
				
			if (i===3){	
				for(l=1; l<=div; l++){
				pointslist+="("+tip[0]+","+tip[1]+",0),";
				tip[0]-=sL;
				}
			}
				
			if (i===4){	
				for(m=1; m<=div; m++){
				pointslist+="("+tip[0]+","+tip[1]+",0),";
				tip[1]-=sL;
				}
			}
		}
	

	pointslist=pointslist.slice(0,-1);
	crv=SICreateCurve("Linear_Curve_Square", 1, 1);
	SISetCurvePoints( crv, pointslist, false );
	ApplyTopoOp("CrvOpenClose", crv, 3, siPersistentOperation, null);
	LogMessage("Succesfully created a Linear Curve Square.\n"+div+" divisions per side.\nSide lenght:"+SqSL+"\nSection Lenght="+sL+"\nHypotenuse:"+Hypo+"\nArea:"+Area);
	}
	else{LogMessage("Error, Divisions to 1 or more" );
	
	}
Here is an example of output in the log with 250 sections per side results to a square with 1000 points and suprisingly is still generated fast (less than 1s):
// INFO : Succesfully created a Linear Curve Square.
// 250 divisions per side.
// Side lenght:4
// Section Lenght=0.016
// Hypotenuse:5.656854249492381
// Area:16
Bellow is the square code put in a loop 4 times + every point is moved to z a certain value, then added a smooth op
And a second square used for the x (scaled mid points to center)+ a typical extrude alond curve.
Image
Tried also to change that last code to create starways, but failed :p or run out of time or both.
Last edited by mc_axe on 07 Jan 2018, 19:56, edited 1 time in total.

User avatar
myara
Posts: 403
Joined: 28 Sep 2011, 10:33

Re: Parametric modeling (Closed linear curves for start)

Post by myara » 05 Jan 2018, 10:52

I'm not sure I understand what are tou trying to do, but you could try CreateCurve instead.
It allows you to put in coordinates so I think it should probably be easier for some cases.

I think it would be kinda troublesome to handle these position arrays with JScript. Python would be a better alternative.

Code: Select all

//JS
positions = "(0,0,0), (0,1,0), (1,1,0), (1,0,0), (0,0,0)"
crv = CreateCurve( 1, 0, positions, false)('Value')
LogMessage ( crv )
M.Yara
Character Modeler | Softimage Generalist (sort of)

User avatar
mc_axe
Posts: 415
Joined: 12 Mar 2013, 18:44

Re: Parametric modeling (Closed linear curves for start)

Post by mc_axe » 06 Jan 2018, 02:00

Hey Martin thx for the post! For a start i just try to generate some 2D shapes with a litl bit more information printed in the log.
Manipulating in real time variables with a UI and a slider or having select boxes for different definitions, would be way more interactive & cool, can I use python for it? Coordinates on curve :-o where can i use them, can u elaborate a litl?
I have the tinyest knowledge on Python, if it is more flexible ill consider trying it :). I alrdy do cause its being said by mYara.

---

Now lets continue the diary of nub scripter:
While I was working on my next challenge (yet another shape) i wanted to add the option for the user (me :)) ) for varius inputs that can define a shape. For example define a shape by area, or a certain sidelenght or a certain angle etc or even by combinations. That sounded really parametric to me, a bounce of parameters that can define a certain shape.

When i tried this on a more complicated shape, i came across alot of parameters and combinations, hence the script would end up with too many conditional statements followed by different solutions for every different kind of input. My first idea to overcome this challenge was a loop, that calls repeatedly some functions attempting to solve variables by using their in between relationships, In the end after a brain meltdown, I managed to provide suficient relations, and the script managed to solve the shape within 1 to 5 loops (ofcourse only if the inputs was sufficient).

Then i presented this type of code to a friend of mine which is really good at programming, and he find it hillarius, he then took the code and converted it to something crazy that dosnt even use my "solving loop idea" insted he uses all kinds of crazy things that i barelly undertand in programming (the relations are still there of course). Is essentially the same thing but is also optimized. I hope that i can understand how it works in order to use it in more shapez.

Will upgrade soon

User avatar
myara
Posts: 403
Joined: 28 Sep 2011, 10:33

Re: Parametric modeling (Closed linear curves for start)

Post by myara » 06 Jan 2018, 13:09

I kinda understand what are you trying to do, I just don't understand how are you going to treat your parameters to make it an all around tool. I mean if you want square based figures, you can add tons of parameters to change the square parts like corners, etc. But how are you going to use these same parameters for figures that are totally different. A tool to creating only regular polygons from triangles to megagons wouldn't be that difficult to do. But going from regular polygons to that bridge is a huge step.

My suggestion in using CreateCurve was because you can assign coordinates (x,y,z) per point, and the command will create a curve in those coordinates so you can use an array to gather your coordinates, and at the very last, use one command to create the entire curve. But I didn't noticed that more or less you are doing the same but in 2 commands so my advice is kinda pointless, sorry :P

My comment about Python and JScript was because JScript isn't good with multidimensional arrays, and the CreateCurve command wanting to have the 3 coordinates inside parenthesis. JScript won't be able to translate arrays properly, it will always "look" like a single dimensional array, so you would have to convert that array into a string that CreateCurve likes. Not that hard to do though.
But !
I didn't notice that you are not using arrays but a big string, so that should work good enough as long as you get a string that Softimage likes.

Just to elaborate what I was trying to say. You can create a JScript array with arrays inside like this:

positions = [[0,0,0], [0,1,0], [1,1,0], [1,0,0], [0,0,0]]

but it will always log:

LogMessage ( positions )
// INFO : 0,0,0,0,1,0,1,1,0,1,0,0,0,0,0

So you would have to convert it to something CreateCurve likes with a function, adding parenthesis every 3 characters in your array.

In Python you would just convert it to string and strip the brackets easily.

positions = [(0,0,0), (0,1,0), (1,1,0), (1,0,0), (0,0,0)]

LogMessage ( positions )
# INFO : [(0, 0, 0), (0, 1, 0), (1, 1, 0), (1, 0, 0), (0, 0, 0)]

So you could make it easily CreateCurve friendly like this:

LogMessage ( str(positions)[1:-1] )
# INFO : (0, 0, 0), (0, 1, 0), (1, 1, 0), (1, 0, 0), (0, 0, 0)

If you are starting to script, and you can choose your language I'd recommend Python.
Probably a little harder to start with, but with a lot more tools to play with in the future, when you have accumulated more knowledge. Being able to using it in other packages like Maya or Max, and having tons of free sample code around the internet is also a big plus.
The only problem with Python is that it isn't very good handling Softimage Collection Objects. It is very slow at it. Besides that, you'll have way more weapons than JScript.
In this specific case though, Python per se won't give you any extra super power, it will only be a little easier to write.

And another suggestion, in your code you are using a different variable for every loop. Since you are separating them with "ifs", you don't need to name them differently, just copy & paste the code and make the modifications.
M.Yara
Character Modeler | Softimage Generalist (sort of)

User avatar
mc_axe
Posts: 415
Joined: 12 Mar 2013, 18:44

Re: Parametric modeling (Closed linear curves for start)

Post by mc_axe » 06 Jan 2018, 20:56

Hey m thanx for awesome rply :)
I see Python handles arrays nicelly, will try to invest more on Python for the future, ill keep using JS till i fugure it out (not too much of a problem yet).
One thing that i would like to ask, is how can I name my curve so its not conflicting with the previus one genereated by same script.

A good idea for an addon that just came to my mind, and could help to create more accurate shapes (sorry if it exists alrdy)
Is a ruler that helps with scaling, the ruler is just one str8 line with 2 points, u can snap anywhere and apply it on a certain selectin then you enter the value you want on the ruler (exact length) and the selection is scaled all together.
I can imagine a more complicated version of that ruler with option to have one end of the ruller fixed in space or 2 sets of constraints for each point , and even more tools like a snapable protractor that handles geo but ill stop here.

The bridge was just an imaginary example, it looks like is following some cetrain rules but i can only do speculations about it, i might give it a go some day :ymdaydream: .

User avatar
rray
Moderator
Posts: 1774
Joined: 26 Sep 2009, 15:51
Location: Bonn, Germany
Contact:

Re: Parametric modeling (Closed linear curves for start)

Post by rray » 06 Jan 2018, 21:21

good tips in here !
mc_axe wrote: 06 Jan 2018, 20:56 One thing that i would like to ask, is how can I name my curve so its not conflicting with the previus one genereated by same script.
It should be possible to store the result of the creatae curve command in a varibable and then use this variable instead of the curve name in the add points function
softimage resources section updated Jan 5th 2024

Post Reply

Who is online

Users browsing this forum: No registered users and 26 guests