Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® Softimage® / XSI SDK / any one know how to access a primitives global component positions?
  RSS 2.0 ATOM  
2 pages: 1.2 last

any one know how to access a primitives global component positions?
Rate this thread
 
30195
 
Permlink of this thread  
avatar
  • QuentinB
  • Posted: 28 April 2009 06:09 PM
  • Location: New York
  • Total Posts: 57
  • Joined: 07 July 2008 04:39 PM

I’m in the middle of writing a script that duplicates an object based on the number of points on a given piece of geometry and which also translates each duplicate to the given points. Its working, but at the moment im only able to access the local point component positions but i need the global component positions. Any one know how I can get to it? right now I’m using ActivePrimitive.Geometry.Points.PositionArray



Falun Dafa
A meditative practice for the mind and body
http://www.falundafa.org

Replies: 0
avatar

You can convert to global with XSIMath.MapObjectPositionToWorldSpace



Replies: 0
avatar
  • QuentinB
  • Posted: 29 April 2009 07:32 AM

Thanks! I’m sure thats what I need to do. I’m trying it out, but I keep getting com errors, its telling me that the position I’m providing to convert is not a com object, I looked over my code in all the ways I know how, so I’m a bit confused at the moment ^_^



Falun Dafa
A meditative practice for the mind and body
http://www.falundafa.org

Replies: 0
avatar
  • CiaranM
  • Posted: 29 April 2009 08:07 AM

Show us your code.



Replies: 0
avatar
  • QuentinB
  • Posted: 29 April 2009 09:45 AM

Forgot to mention I’m using python...........

The code as requested:

import win32com

XSIMath = win32com.client.Dispatch( “XSI.Math” )

#Define Application
xsi=Application

#Define selected object
rtn=xsi.PickElement("","Pick An Object”, “Pick An Object")
oDob=rtn[2]

#Define Object to duplicate onto
rtn=xsi.PickElement("","Pick Destination Object”, “Pick Destination Object")
oCob=rtn[2]

oTrans = oCob.name+".Kinematics.Local.Transform"
oPoint = oCob.name+".ActivePrimitive.Geometry.Points.Position"

Application.LogMessage (oPoint)

XSIMath.MapObjectPositionToWorldSpace (oTrans,oPoint)

Thanks!!



Falun Dafa
A meditative practice for the mind and body
http://www.falundafa.org

Replies: 0
avatar

oTrans oCob.name+".Kinematics.Local.Transform"
oPoint oCob.name+".ActivePrimitive.Geometry.Points.Positi on"

oTrans and oPoint are strings.

Points is a collection; you need to do something like Points(0).Position



Replies: 0
avatar
  • QuentinB
  • Posted: 29 April 2009 10:44 AM

Hello,

I tried that already as well as using the commands directly instead of the variables, but the xsimath still returns the same error. Could someone run it and give a go and trying to debug the problem, I figure it is because I’m accessing a collection, but putting (0) there didnt change anything. Also if I only put one number there, I would not be able to access each points position right?

Thanks!!!



Falun Dafa
A meditative practice for the mind and body
http://www.falundafa.org

Replies: 0
avatar
  • CiaranM
  • Posted: 29 April 2009 12:09 PM

Basically, the XSIMath method accepts an siVector3 object as input, so you need to construct one of those from each point position. The positionArray is handy to get the ordered point positions.
This is an example run on a simple cube.  It uses mapped lambda functions, which pretty much allow you to encapsulate an whole ‘for...in’ statement in a single line. Regular loops would work just as well.

import win32com
XSIMath 
win32com.client.Dispatch"XSI.Math" )

#Define Application
xsi=Application

oCob 
xsi.Selection(0)

oTrans oCob.Kinematics.Local.Transform

#Get a 2D array of point positions i.e x,y or z value per point
posArr oCob.ActivePrimitive.Geometry.Points.PositionArray

#build an array of siVectors from the positionArray components, using a mapped lambda function
#XSIMath.CreatVector3() is the function
#the posArr indices are the x, y, z arguements in that order
vecArr map(lambda x,y,zXSIMath.CreateVector3(x,y,z), posArr[0]posArr[1]posArr[2])

xsi.logmessage('Local space')
map(lambda abxsi.logmessage(str(b) + ': ' str(a.X) + ' ' str(a.Y) + ' ' str(a.Z)), vecArrrange(len(vecArr)))
xsi.logmessage('######################')

#Again, use a mapped lambda function to pass the entire array through the XSIMath method at once
mappedVecArr map(lambda xXSIMath.MapObjectPositionToWorldSpace(oTransx), vecArr

xsi.logmessage('World space')
map(lambda abxsi.logmessage(str(b) + ': ' str(a.X) + ' ' str(a.Y) + ' ' str(a.Z)), mappedVecArrrange(len(mappedVecArr)))
xsi.logmessage('######################')


Replies: 0
avatar
  • QuentinB
  • Posted: 29 April 2009 12:17 PM

Thanks!!! I will try this out asap!!



Falun Dafa
A meditative practice for the mind and body
http://www.falundafa.org

Replies: 0
avatar
  • QuentinB
  • Posted: 29 April 2009 12:49 PM

Now that the points position values are mapped to world space, will reusing

ActivePrimitive.Geometry.Points.PositionArray

get me the new position values? Reason I asked is because I tried that lol and I still get a local value. I’m trying to make a copy script where I can copy a geo object onto the points of another object, and it works without have to convert the spaces except that it only works based on local position so I ran into some issues with some meshes, so thats why I needed to convert the positions to a world space ^_^ so, I know reusing ActivePrimitive.Geometry.Points.PositionArray is not giving me those new values, any suggestions?



Falun Dafa
A meditative practice for the mind and body
http://www.falundafa.org

Replies: 0
avatar
  • QuentinB
  • Posted: 29 April 2009 12:52 PM

or do I now need to get the length of the mappedVecArr? right now I using

for p in range(len(pa[0])):
null = xsi.SIDuplicate(oDob)
xsi.Logmessage(null)
tmp=null[0]
t = tmp.Kinematics.Global.Transform
t.SetTranslationFromValues(pa[0][p], pa[1][p], pa[2][p])
tmp.Kinematics.Global.Transform = t



Falun Dafa
A meditative practice for the mind and body
http://www.falundafa.org

Replies: 0
2 pages: 1.2 last