OO_addnullstopoint script

120 views
Skip to first unread message

Gerbrand Nel

unread,
Jul 19, 2012, 7:49:43 AM7/19/12
to xsi group
Ok this might give away my age, but I remember a time when the "add
nulls to points" script gave you a choice between constrain to nulls,
and constrain points to nulls.
In 2013 it only constrains to the nulls.
Anyone know where I can find a script to create nulls on selected
points, constrained to those points?
I saw some Ice stuff to do this on rray.de, but I miss the old way.
Thanks guys
G

Juan Brockhaus

unread,
Jul 19, 2012, 8:11:06 AM7/19/12
to soft...@listproc.autodesk.com
Hi Gerbrand,

Here is a script of mine which does that (and more).

It copies objects to a selection.

Select components or objects, run script and select your options.

It works with selection of components or objects. Depending of what is
selected the options are different.

The picked object will be branch-duplicated. So it can also be a root of
a hierarchy.

If you are in the picking session you can middle-click anything and it
will create a null and duplicate that null around. So no need to create
a null first and then pick it. (It is a bit awkward that you have to
middle-click something, but for softimage to recognize a pick session
you need to pick something... didn't find another way round it)

And if you pick a group, it will randomly duplicate the group members to
your selection. (and there is a tab where you can define the relative
amount)


Hope that helps.

Cheers,

Juan




- - -
Juan Brockhaus | Head of CG Studio
Prime Focus London Commercials
T: +44 (0)20 7565 1000 | M: +44 (0)7944 720 557
A: 37 Dean Street, London, W1D 4PT, UK
www.primefocusgroup.com
duplicate_obj_to_selection.zip

Claudio Pavan

unread,
Jul 19, 2012, 8:15:22 AM7/19/12
to soft...@listproc.autodesk.com
'###########################################################################
#####
'NAME: Add Null To Point v2.0
'AUTHOR: Olivier Ozoux <oliv...@softimage.com>
'LAST MODIFIED: 2001-05-22
'
'v2.0 is a complete rewrite using the Object Model where possible
'
'INSTALL
'
'1. Copy the SPDL file:
' {5CD342AD-2FB1-4646-9D14-3E82C805177D}.spdl
' to the spdl directory of XSI (for example):
' C:\Softimage\XSI_1.5\Application\spdl
'
'2. Copy the Preset file:
' AddNullToPointDialog.Preset
' to the Preset Property directory of XSI (for example):
' D:\Softimage\XSI_1.5\DSPresets\Properties
'
'3. Restart XSI
'
'4. Run the Script or Create a Command/Button on a toolbar
'
'
'This tool will create a single Null for each point of the selected
object(s).
'(you can also select a point cluster, or tag points). Then based on the
dialog
'choice, it will either Constrain the Null to the Point using Object to
Cluster
'constraint, or Deform the point to the Null with a Cluster Center operator.
'
'-Olivier Ozoux
'###########################################################################
####
Option Explicit


AddNullToPointProc


'---------'---------'---------'---------'---------'---------'---------'-----
----
sub AddNullToPointProc()
'---------'---------'---------'---------'---------'---------'---------'-----
----
Dim oSel, Name, Parent, Mode, oDialog

'Create the dialog
set oDialog = CreateUIDialog
On Error Resume Next
InspectObj oDialog,,,4
if Err.Number = 0 then
On Error Goto 0
'Read the dialog values
Mode = oDialog.parameters("CnsType").value
Name = oDialog.parameters("NullName").value
Parent = oDialog.parameters("ParentObj").value
'loop over the selection
for each oSel in selection
addNullToPoint oSel, Mode,Name,Parent
next
end if

'Cleanup
DeleteObj oDialog
end sub

'---------'---------'---------'---------'---------'---------'---------'-----
----
function CreateUIDialog()
'---------'---------'---------'---------'---------'---------'---------'-----
----
Dim oRoot, oDialog, oParam

set oRoot = ActiveProject.ActiveScene.Root
On Error Resume Next
'Try to load the edited dialog first
set oDialog =
oRoot.AddProperty("AddNullToPointDialog",,"AddNullToPoint")
if Err.Number <> 0 then
'Build a custom dialog
set oDialog =
oRoot.AddProperty("Custom_Parameter_List",,"AddNullToPoint")
set oParam = oDialog.AddParameter("CnsType", siInt4,,4,,
"Constrain Type", , 0, 0, 1)
set oParam = oDialog.AddParameter("NullName",
siString,,4,,"Null Names",,"<name>_Null")
set oParam = oDialog.AddParameter("ParentObj",
siBool,,4,,"Parent Nulls ",,TRUE)
end if

oDialog.parameters("NullName").Value = "<obj>_pnt"
'Return the Dialog Object
set CreateUIDialog = oDialog
end function



'---------'---------'---------'---------'---------'---------'---------'-----
----
sub addNullToPoint(oSel, Mode, Name, Parent)
'---------'---------'---------'---------'---------'---------'---------'-----
----
Dim oRoot, oGeom, oPoints, oCls, oNull
Dim aTmp(), i, aIndex, tmp, pntName

'There are 3 cases we support
'1 oSel is a Geometry object (poly,srf,curve)
'2 oSel is a tagged selection
'3 oSel is a point Cluster

set oRoot = ActiveProject.ActiveScene.root
'First Case
if oSel.type = "polymsh"_
Or oSel.type = "surfmsh"_
Or oSel.type = "crvlist" then

set oGeom = oSel.ActivePrimitive.Geometry
set oPoints = oGeom.Points

'Create a 1:1 index array
redim aTmp(oPoints.count -1)
for i=0 to oPoints.count -1
aTmp(i) = i
next
aIndex = aTmp

'Second Case
elseif oSel.type = "pntSubComponent" then

'this is a tag selection.
aIndex = oSel.subelements

'Workaround to get the object from the selection
tmp = split(oSel, ".")
if ubound(tmp) = 2 then
'under a model
oSel = tmp(0) & "." & tmp(1)
else
'under the scene_root
oSel = tmp(0)
end if
set oSel = getvalue(oSel)

if oSel.type = "polymsh"_
Or oSel.type = "polymsh"_
Or oSel.type = "surfmsh"_
Or oSel.type = "crvlist" then
set oGeom = oSel.ActivePrimitive.Geometry
set oPoints = oGeom.Points
else
logmessage "Not a valid Geometry!"
exit sub
end if

'Third Case
elseif oSel.type = "pnt" then

'It's a Point Cluster
aIndex = oSel.Elements.Array
set oGeom = oSel.Parent

'workaround to get the object from the cluster
tmp = split(oSel, ".")
if ubound(tmp) = 4 then
'under a model
oSel = tmp(0) & "." & tmp(1)
else
'under the scene_root
oSel = tmp(0)
end if
set oSel = getvalue(oSel)

set oPoints = oGeom.Points
else
logmessage "Not a Geometry!"
exit sub
end if

'Mangle a name together, replacing <obj> with the real name of the
object.
pntName = Replace(Name, "<obj>", oSel.name)

'Start going thru the points in the index
for i=0 to uBound(aIndex)

'Create a Cluster with that point
set oCls = oGeom.addCluster( "pnt", "pnt" & aIndex(i),
array(aIndex(i)) )

'Create a Null
set oNull = oSel.AddNull( pntName & aIndex(i) )

Select Case Mode
Case 0 'Null to Point
'Constrain the Null to the Cluster
oNull.Kinematics.AddConstraint
"ObjectToCluster", oCls, False

Case 1 'Point to Null
'Move the Null in position

oNull.kinematics.local.parameters("posx").value =
oPoints(aIndex(i)).position.x

oNull.kinematics.local.parameters("posy").value =
oPoints(aIndex(i)).position.y

oNull.kinematics.local.parameters("posz").value =
oPoints(aIndex(i)).position.z

'Create ClusterCenter
ApplyOperator "ClusterCenter", oCls & ";" &
oNull , 0
End Select

'Cut The Null iff needed
if Parent = False then
CutObj oNull
end if
next
end sub





-----Original Message-----
From: softimag...@listproc.autodesk.com
[mailto:softimag...@listproc.autodesk.com] On Behalf Of Gerbrand Nel
Sent: Thursday, July 19, 2012 1:50 PM
To: xsi group
Subject: OO_addnullstopoint script

Juan Brockhaus

unread,
Jul 19, 2012, 8:16:30 AM7/19/12
to soft...@listproc.autodesk.com

Apparently my mailserver didn't let my mail get through due to a zip
attachments...

So here is another attempt. (change .js__BLABLA to .js)


A quick correction on how to use the script:
- select components or object
- run script
- pick object to be duplicated
- select your options



Here my original mail:



Hi Gerbrand,

Here is a script of mine which does that (and more).

It copies objects to a selection.

(Select components or objects, run script and select your options.)

It works with selection of components or objects. Depending of what is
selected the options are different.

The picked object will be branch-duplicated. So it can also be a root of
a hierarchy.

If you are in the picking session you can middle-click anything and it
will create a null and duplicate that null around. So no need to create
a null first and then pick it. (It is a bit awkward that you have to
middle-click something, but for softimage to recognize a pick session
you need to pick something... didn't find another way round it)

And if you pick a group, it will randomly duplicate the group members to
your selection. (and there is a tab where you can define the relative
amount)


Hope that helps.

Cheers,

Juan






- - -
Juan Brockhaus | Head of CG Studio
Prime Focus London Commercials
T: +44 (0)20 7565 1000 | M: +44 (0)7944 720 557
A: 37 Dean Street, London, W1D 4PT, UK
www.primefocusgroup.com


-----Original Message-----
From: softimag...@listproc.autodesk.com
[mailto:softimag...@listproc.autodesk.com] On Behalf Of Gerbrand
Nel
Sent: 19 July 2012 12:50
To: xsi group
Subject: OO_addnullstopoint script

duplicate_obj_to_selection.js__BLABLA

Gerbrand Nel

unread,
Jul 19, 2012, 8:35:58 AM7/19/12
to soft...@listproc.autodesk.com
Thanks guys
-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2012.0.2197 / Virus Database: 2437/5141 - Release Date: 07/19/12

Reply all
Reply to author
Forward
0 new messages