ScriptSpot

Forum topic · General Scripting

Help - if condition

By jsrocha · 2011-10-24

Description

hi guys, i need a little help from you. I use a script to position vertices from polys and splines in x/y/z position, and i need an "if" condition to make the the script work better. What i need is, if the selected object is a poly object, the script runs a line of code, if not, it continues without that line. Is it to difficult to do? i´m not a coder, i just edit some existing scripts and use macrorecorder a lot :)

i´ll put the code i have now here (this is an edited neil blevins's script):

(

oldGrid = activeGrid -- store curr. active grid

activeGrid = undefined -- activate the home grid

toolMode.coordsys #world

macros.run "Objects Helpers" "ActivateHomeGrid"

snapmode.active = true

-- here is where i need an if condition, to be able to use the same script to a poly and a spline. So, if the selected object is a poly, the script will run the next line:

macros.run "Editable Polygon Object" "EPoly_Convert_Sel_To_Vertex"

-- and then continues to the rest of the script:

macros.run "SoulburnScripts" "vertPlacer"

activeGrid = oldGrid -- activate prev. active grid

)

 

if the object is a spline, the line "macros.run "Editable Polygon Object" "EPoly_Convert_Sel_To_Vertex" must be ignored. Can anyone help me to do that??

thanks in advance,

Jsrocha

Comments (2)

i got it!

jsrocha · 2011-10-24

Hi guys, i think i figured out myself :D

oldGrid = activeGrid -- store curr. active grid
activeGrid = undefined -- activate the home grid
actionMan.executeAction 0 "40083" -- ativa home grid
macros.run "Coordinate System" "Coordsys_World"
snapmode.active = true

if (superclassof $==Geometry)
then
( macros.run "Editable Polygon Object" "EPoly_Convert_Sel_To_Vertex"
)

macros.run "SoulburnScripts" "vertPlacerYMouseClick"
activeGrid = oldGrid -- activate prev. active grid

i found a pdf document here in the foruns wich have an example that fits what i need. thanks,

Jsrocha

ops

jsrocha · 2011-10-24

Hi guys,
unfortunetly, the code i inserted in the script doesn´t work the way it should. The line " macros.run "Editable Polygon Object" "EPoly_Convert_Sel_To_Vertex"" must turn an edge or face selection into vertex, but is not working with the if statement that i wrote. So i still need some help from you :)
Thanks in advance,

Jsrocha