Importing huge amount of points?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  08 August 2012
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!!
 
  09 September 2012
OpenMaya has an emit function that can take as an input an array.
 
  09 September 2012
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 September 2012 at 09:16 PM.
 
  09 September 2012
ok just a general tip:

when you create something with a command you can store it in a variable
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:

"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 ).
 
  09 September 2012
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)) )
 
  09 September 2012
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.
 
  09 September 2012
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.
 
  09 September 2012
Couldn't find a way to upload my points data, otherwise you guys might get better understanding how slow it is..

:(
 
  09 September 2012
Please supply code and data.
 
  09 September 2012
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!
 
  09 September 2012
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



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 07:45 AM.


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