CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 08-31-2012, 06:57 PM   #1
bigheadben
New Member
portfolio
ben
los angeles, USA
 
Join Date: Aug 2012
Posts: 4
Importing huge amount of points?

I have a .txt file with 300thousand+ coordinates.
So, it looks like
1 4 5
123 4221 5532
2 3423 555

etc. 300thousand + line.

what I'm trying to do is import them all into maya.

so I wrote to script and store all coordinate into a list called pointCoord and
trying to create the point or particle in maya.

However, it is super slower compare to houdini, it took me like 25 mins for one fram
my first try was "mc.nParticle(name = 'Test1', p = pointCoord)" it took me 25 mins for create
the points. "mc.particle(name = 'Test1', p = pointCoord)" is a bit faster but still took me like 20 mins.

Any way to make it at least 1 mins 1 frame?

Thank you very much!!
 
Old 09-02-2012, 08:34 PM   #2
zoharl
A newbie
 
zoharl's Avatar
portfolio
Zohar
Wellington, New Zealand
 
Join Date: Mar 2009
Posts: 1,820
OpenMaya has an emit function that can take as an input an array.
 
Old 09-02-2012, 09:00 PM   #3
stooch
Lord of the posts
 
stooch's Avatar
portfolio
Dimitri Loginowski
VFX Artist + Designer
Handsome, LLC
Beverly Hills, USA
 
Join Date: Apr 2004
Posts: 2,029
Send a message via AIM to stooch
if you have PyMel
you simply do the following:

import pymel.core as pm
pm.nParticle( p=[(0, 0, 0), (3, 5, 6), (5, 6, 7), (9, 9, 9)] )

so you can easily pass an array,

pymel uses openmaya for most of its hooks, so you are actually getting a speed boost from it as well, and a much easier and more streamlines syntax than open maya.

also in general maya slows down if you specify an object name, ie
pm.nParticle( n="particleName", p=position )

what you are telling maya is to do an evaluation on the dependency graph to resolve the maya node that matches "particleName", which is a pretty involved process.

its much more efficient to send an array of positions as demonstrated above because maya doesnt have to "find" a node "particleName" 300,000 times. It just creates a particle shape and fills it with the array. much faster.

in general, if you want your iteration loops to be most efficient in maya, its better to
select a node, and then perform your iterations without specifying a particular node, this way maya can assume that you are adressing the selected node every time.

in general you should structure all of your code with the goal to pass as much information as arrays as possible. So that maya does operations in bulk.

even the simple command ls("itemName") is less efficient than ls("itemName", type="itemType").

why? well, in the first example maya has to compare all items in the scene and find the correct name, while the second example compares all items that are of a specific type. Its less items to compare against.
__________________
From Russia, with love @ stooch.tv

Last edited by stooch : 09-02-2012 at 09:16 PM.
 
Old 09-02-2012, 09:45 PM   #4
tontonsuspect
puppet tamer
cedricB
CharacterTD
France
 
Join Date: May 2004
Posts: 145
ok just a general tip:

when you create something with a command you can store it in a variable
Code:
import maya.cmds as cmds prtSys = cmds.nParticle(n='testSystem')


it will return # Result: [u'testSystem', u'testSystemShape'] #
here you will of course not write your position by calling your object name:
Code:
"mc.particle(name = 'Test1', p = pointCoord)" #bad habit dont do this partclePos = [(0, 0, 0), (3, 5, 6), (5, 6, 7), (9, 9, 9)] cmds.nParticle(prtSys[1], e=True, p = partclePos) #


In maya you dont need to select something to modify it and no, it is not better to select things to write their attribute( on the contrary in 3dsmax you have to open the modify panel to access some scripting functionality--> super slow but mandatory ).
 
Old 09-02-2012, 09:50 PM   #5
tontonsuspect
puppet tamer
cedricB
CharacterTD
France
 
Join Date: May 2004
Posts: 145
I dont do Fx works at all but in the documentation there is also the command emit:
cmds.emit( object=prtSys[1], position=((1, 1, 1), (2, 2, 2)) )
 
Old 09-06-2012, 05:29 PM   #6
bigheadben
New Member
portfolio
ben
los angeles, USA
 
Join Date: Aug 2012
Posts: 4
Quote:
Originally Posted by stooch
if you have PyMel
you simply do the following:

import pymel.core as pm
pm.nParticle( p=[(0, 0, 0), (3, 5, 6), (5, 6, 7), (9, 9, 9)] )

so you can easily pass an array,

pymel uses openmaya for most of its hooks, so you are actually getting a speed boost from it as well, and a much easier and more streamlines syntax than open maya.

also in general maya slows down if you specify an object name, ie
pm.nParticle( n="particleName", p=position )

what you are telling maya is to do an evaluation on the dependency graph to resolve the maya node that matches "particleName", which is a pretty involved process.

its much more efficient to send an array of positions as demonstrated above because maya doesnt have to "find" a node "particleName" 300,000 times. It just creates a particle shape and fills it with the array. much faster.

in general, if you want your iteration loops to be most efficient in maya, its better to
select a node, and then perform your iterations without specifying a particular node, this way maya can assume that you are adressing the selected node every time.

in general you should structure all of your code with the goal to pass as much information as arrays as possible. So that maya does operations in bulk.

even the simple command ls("itemName") is less efficient than ls("itemName", type="itemType").

why? well, in the first example maya has to compare all items in the scene and find the correct name, while the second example compares all items that are of a specific type. Its less items to compare against.


I have tried them all, it is still very slow I already waited for 10mins and it doesn't come up yet.
 
Old 09-06-2012, 05:34 PM   #7
bigheadben
New Member
portfolio
ben
los angeles, USA
 
Join Date: Aug 2012
Posts: 4
Quote:
Originally Posted by tontonsuspect
I dont do Fx works at all but in the documentation there is also the command emit:
cmds.emit( object=prtSys[1], position=((1, 1, 1), (2, 2, 2)) )

Thank you very much, but it doesn't help.

for cmds.particle(theName, e=True, p= pointCoord), pop up an error saying that

# Error: RuntimeError: Flag not valid in edit: -p #

which means we can only create the particle and tell them the position during creation.
 
Old 09-06-2012, 05:39 PM   #8
bigheadben
New Member
portfolio
ben
los angeles, USA
 
Join Date: Aug 2012
Posts: 4
Couldn't find a way to upload my points data, otherwise you guys might get better understanding how slow it is..

:(
 
Old 09-08-2012, 06:26 AM   #9
zoharl
A newbie
 
zoharl's Avatar
portfolio
Zohar
Wellington, New Zealand
 
Join Date: Mar 2009
Posts: 1,820
Please supply code and data.
 
Old 09-08-2012, 09:04 AM   #10
NaughtyNathan
HighEnd3D deserter
 
NaughtyNathan's Avatar
Naughty Nathan
Technical Artist
Sony SCEE Liverpool
Manchester, United Kingdom
 
Join Date: May 2008
Posts: 2,608
if you already have an ascii file on disk with all the point info in it it would probably just be quicker to append a .ma Maya ASCII file header and footer into the file thus converting it into an actual .ma file that you could then load or import directly!
 
Old 09-08-2012, 09:04 AM   #11
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 04:14 PM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.