PDA

View Full Version : fixing meshes!


sheb
11-03-2005, 11:29 AM
HELLO!

Sorry heres a really small question. Sometimes we get weird things happening to meshes, like scary flickering in the modify panel while collapsing. The only way of getting rid of that seems to be to export the bad meshes and import them again. So I wrote a quick little script to automate it:



fn fixmesh objs =
(
objs = makeobjarray objs
if objs == undefined do return false
for obj in objs do (
local modHolder = (copy obj)
modholder.name = "modholder"
local name = obj.name
for m in obj.modifiers do m.enabled = false
ExportFile "C:\\temp.obj" #noprompt selectedOnly:true
Delete obj
ImportFile "C:\\temp.obj" #noprompt


local o = getnodebyname ("obj"+name)
o.name = name
select o

for m in modholder.modifiers do modPanel.addModToSelection (copy m)
delete modholder
)
)


fixmesh $





The strange thing is that the modifier idea doesnt work, does anybody know why? I tried all kinds of ways of adding them. The result is always the modifer but it doesnt do anything anymore :/. When i copy over the modifier by hand it obvisously works :banghead:

Any ideas?

Thanks already!

sebbbb

j-man
11-03-2005, 12:43 PM
sheb,

Firstly, name is a reserved word. Secondly, you're referencing an object that you've deleted! and... what's this - makeobjarray



fn fixmesh objs =
(
-- objs = makeobjarray objs
if objs == undefined do return false
for obj in objs do (
modHolder = (copy obj)
modholder.name = "modholder"
nme = obj.name
for m in obj.modifiers do m.enabled = false
ExportFile "C:\\temp.obj" #noprompt selectedOnly:true
-- Delete obj
ImportFile "C:\\temp.obj" #noprompt


o = getnodebyname ("obj"+nme)
o.name = nme
select o
for m in modholder.modifiers do modPanel.addModToSelection (copy m)
delete modholder
)
delete objs
)


fixmesh $


oh, and be careful because you obj is imported as a group.

Josh.

sheb
11-03-2005, 01:01 PM
yay!!

The deleteing bit was what caused it!! i thought "obj" wouldnt actually be accessed anymore after i made a copy of it and i didnt know about the name thing. Thanks!

the makeobjarray is just alittle thing that checks if objs is actually an array and not a single object.


Thanks again!

seb :bounce:

j-man
11-03-2005, 03:53 PM
the makeobjarray is just alittle thing that checks if objs is actually an array and not a single object.

Ah,

well you don't need it. If you replace the last line :

fixmesh $

with:

fixmesh selection

then there wont be a problem since the selectionset is always an array, even when it's one object.
or even better, selection as array.

FYI you should never use $ in a script and here is a chat I just had before about why

http://forums.cgsociety.org/showthread.php?t=290456

Glad your script works now!

Josh.

CGTalk Moderation
11-03-2005, 03:53 PM
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.