Notifications
Clear all

[Closed] Flipping normals script

I am wanting to make a script that when i import and object it will go through them one by and and flip the normals.

how would you go about doing this.

it is a am having a problem importing a dxf file and the unfiy normals doesn’t help

6 Replies

<code>
for obj in geometry do
(
addmodifier obj (normalModifier())
obj.modifiers[#Normal].flip = true
)

</code>

Khye

thanks, that works great,

you are a life saver

would have taken ages to do manually

:bowdown:

Originally posted by whitehorse
[B]thanks, that works great,

you are a life saver

would have taken ages to do manually

:bowdown: [/B]

It would’t
Set selection filter in Main Toolbar to Geometry,
select all objects, add a Normal modifier on top of them all, check a checkbox. The script does the same.
(Not that I am against scripting or something… :))

Just for the fun of it, the script could be written in a single line without a loop as


addModifier geometry (normalModifier flip:true)

AddModifier is mappable, geometry is a collection that can be mapped to, and the normal modifier can be applied as instance to all objects with the parameter flip already set to true.

Sorry, I know, I am a smartA**

well that is another way to do it

Just when you think you’re out of grasshopper school . . .

Khye

Originally posted by oatz
[B]Just when you think you’re out of grasshopper school . . .

Khye [/B]

Sorry, I hope I did not offend you. (if it did, please accept my public apology!)

I have to admit that if I would have to answer the question, I would have supplied the code you did. But then, when you see someone’s code, you start thinking – hmmm, is it possible to get this code shorter? Faster? Does it need a loop? Does it need a unique modifier on each object? Is addModifier mappable? Do I have to explicitly convert geometry to array of does it map directly to it?

So to be honest, I spent some minutes playing with the code and actually LEARNED lots of things myself. Then I posted so other people can learn what I learned.

Once again, sorry if I sounded like “Know It All”, I wasn’t my intention to sound like I know better…

Peace!

Bobo