Notifications
Clear all

[Closed] Problem with trimesh

I am having a code like this:

m=$.mesh
setnumverts m (2*m.numverts)
for v in m.verts do ...

When triing to execute this code geting this mesage:

I tried to insert “update m” befor the for loop, but it was of no use.

5 Replies

When you create with .mesh it’s only a mesh in memory. It can be more stable to create a node and work on that. Note that I delete the node when done, but you can do whatever you like.

(
	m = mesh mesh:$.mesh
	setnumverts m (2*m.numverts)
	
	for v in m.verts do
	(print v)
	
	delete m
)

But I would like to avoid creating node since it have to be manually deleted. I mean when this code is executed many times it´s a performance isue and since I am using old PC with an old max version, performance play a role. I still have acces to the most trimesh values after changing the number of verts exept that verts property.

What exactly do you need to do?
Can you show a complete useful and working code as well as a simple test scene?

Just then someone here might be able to give you a useful tip.

After reading your answer in the other thread it is posibly beter to change

for v in m.verts do ...

to :

for i=1 to m.numverts do
(
 v=getvert m i
...
)

OK, after I have changed

for v in m.verts do ...

to :

for i=1 to m.numverts do
(
 v=getvert m i
...
)

everithing worcks fine.