Code: Select all
SetTransientReferencePlane();
var refMode = GetUserPref("3D_TRANSFO_REFERENTIAL_CHANGED")
if(refMode == 3)
SetUserPref("3D_TRANSFO_REFERENTIAL_CHANGED", 19);//ref(3) + cog(16)
else
SetUserPref("3D_TRANSFO_REFERENTIAL_CHANGED", 3);
Code: Select all
SetTransientReferencePlane();
var refMode = GetUserPref("3D_TRANSFO_REFERENTIAL_CHANGED")
if(refMode == 3)
SetUserPref("3D_TRANSFO_REFERENTIAL_CHANGED", 19);//ref(3) + cog(16)
else
SetUserPref("3D_TRANSFO_REFERENTIAL_CHANGED", 3);
Code: Select all
if(Selection.Filter.Name == "Polygon"){
var sel = selection.GetAsText();
SelectFilter(siEdgeFilter);
var oldEdgeSel = selection.GetAsText();
SelectPolygonOutline(sel);
var BorderEdges = SelectAllUsingFilter("Border_Edge", false, false);
RemoveFromSelection(BorderEdges);
var newEdgeSel = selection.GetAsText();
SelectGeometryComponents(oldEdgeSel);
SelectFilter(siPolygonFilter);
var bevel = ApplyTopoOp("BevelComponent", newEdgeSel);
for(i=0; i<bevel.Count; i++){
bevel(i).Parameters("miter").Value = true;
}
InspectObj(bevel);
}
Code: Select all
# QuickThickness
import win32com.client
from win32com.client import constants
c = win32com.client.constants
null = None
false = 0
true = 1
def XSILoadPlugin( in_reg ):
in_reg.Author = "eistan"
in_reg.Name = "QuickThickness"
in_reg.Major = 1
in_reg.Minor = 0
in_reg.RegisterCommand("QuickThickness","QuickThickness")
in_reg.RegisterMenu(constants.siMenu3DViewObjectMeshContextID,"QuickThickness_Menu",false,false)
in_reg.RegisterMenu(constants.siMenuTbModelModifyPolygonMeshID,"QuickThickness_Menu",false,false)
#RegistrationInsertionPoint - do not remove this line
return true
def XSIUnloadPlugin( in_reg ):
strPluginName = in_reg.Name
Application.LogMessage(str(strPluginName) + str(" has been unloaded."),constants.siVerbose)
return true
def QuickThickness_Init( in_ctxt ):
oCmd = in_ctxt.Source
oCmd.Description = ""
oCmd.ReturnValue = true
return true
def QuickThickness_Execute( ):
a = Application
sel = a.Selection
lm = LogMessage
listx = []
lista = []
for x in range(0, sel.Count):
geo = sel(x).activeprimitive.geometry
geoCount = geo.Edges.Count
selcon = sel(x).activeprimitive.ConstructionHistory
if selcon.Find( "extrudenormalop" ) and selcon.Find( "invsrf" ) and selcon.Find( "invertpolygonop" ) and selcon.Find( "extrudecompaxisop" ):
lista.append(sel(x).Name)
else:
listx.append(sel(x).Name)
if listx:
oProgressBar = XSIUIToolkit.ProgressBar
oProgressBar.Maximum = len(listx)
oProgressBar.Caption = "Quick Thickness Process..."
oProgressBar.Visible = True
for y in range(0, len(listx)):
a.SelectObj(listx[y], "", True)
a.SelectGeometryComponents(".poly[*]")
a.ApplyTopoOp("InvertPolygon", "", "siUnspecified", "siPersistentOperation", "")
a.DuplicateMeshComponent("", "siPersistentOperation", "", "", "", "", "", "", "", "", "", "", "", "", True)
a.ApplyTopoOp("InvertPolygon", "", "siUnspecified", "siPersistentOperation", "")
a.ApplyTopoOp("ExtrudeComponentNormal", "", "siUnspecified", "siPersistentOperation", "")
a.SetValue(a.Selection(0).Name +".polymsh.extrudenormalop.length", 0.1, "")
a.SelectObj(listx[y], "", True)
a.SetSelFilter("Border_Edge")
edge = a.SelectAllUsingFilter("Border_Edge", "siCheckComponentVisibility", "", "")
if edge.Count > 0:
a.ApplyTopoOp("WeldEdges", "", "siUnspecified", "siPersistentOperation", "")
a.ActivateObjectSelTool("")
a.SelectObj(listx[y], "", True)
a.ApplyTopoOp("Inverse", "", 3, "siPersistentOperation", "")
a.SetValue(".polymsh.invsrf.inv", False, "")
oProgressBar.Increment()
Application.SelectObj(listx)
a.ActivateRaycastPolySelTool("")
if lista and listx:
a.AddToSelection(lista)
elif lista:
a.SelectObj(lista)
oProp = XSIFactory.Createobject( 'CustomProperty' )
oProp.Name = "Quick Thickness"
oProp.addparameter2( "Thickness", 5, .1, -100, 100, -5, 5)
oProp.addparameter2( "Subdivs", 2, 0, 0, 100, 0, 5)
oProp.addparameter2( "Inset", 5, 0, -100, 100, -5, 5)
oProp.addparameter2( "Freeze", 5)
oLayout = oProp.PPGLayout
oLayout.AddItem( 'Thickness', "Thickness" , c.siControlNumber)
oLayout.AddItem( 'Subdivs', "Subdivs" , c.siControlNumber)
oLayout.AddItem( 'Inset', "Inset" , c.siControlNumber)
oLayout.AddItem( 'Freeze', "Freeze" , c.siControlButton)
oLayout.Language = "Python"
oLayout.Logic = '''
a = Application
sel = a.Selection
lm = LogMessage
list = []
for x in range(0, sel.Count):
list.append(sel(x))
def Thickness_OnChanged():
for y in range(0, len(list)):
list[y].ActivePrimitive.ConstructionHistory.Find( "extrudenormalop" ).Parameters(1).Value = PPG.Thickness.Value
if PPG.Thickness.Value < 0:
list[y].ActivePrimitive.ConstructionHistory.Find("invsrf").Parameters(0).Value = True
else:
list[y].ActivePrimitive.ConstructionHistory.Find("invsrf").Parameters(0).Value = False
def Subdivs_OnChanged():
for y in range(0, len(list)):
list[y].ActivePrimitive.ConstructionHistory.Find( "extrudenormalop" ).Parameters(6).Value = PPG.Subdivs.Value
def Inset_OnChanged():
for y in range(0, len(list)):
list[y].ActivePrimitive.ConstructionHistory.Find( "extrudenormalop" ).Parameters(2).Value = PPG.Inset.Value
def Freeze_OnClicked():
a.SelectObj(list, "", True)
a.FreezeModeling("", "", "")
PPG.Close()
'''
if listx or lista:
a.inspectobj( oProp , "", "", 3)
return true
def QuickThickness_Menu_Init( in_ctxt ):
oMenu = in_ctxt.Source
oMenu.AddCommandItem("QuickThickness","QuickThickness")
return true
Code: Select all
# QuickThickness
import win32com.client
from win32com.client import constants
c = win32com.client.constants
null = None
false = 0
true = 1
def XSILoadPlugin( in_reg ):
in_reg.Author = "eistan"
in_reg.Name = "QuickThickness"
in_reg.Major = 1
in_reg.Minor = 0
in_reg.RegisterCommand("QuickThickness","QuickThickness")
in_reg.RegisterMenu(constants.siMenu3DViewObjectMeshContextID,"QuickThickness_Menu",false,false)
in_reg.RegisterMenu(constants.siMenuTbModelModifyPolygonMeshID,"QuickThickness_Menu",false,false)
#RegistrationInsertionPoint - do not remove this line
return true
def XSIUnloadPlugin( in_reg ):
strPluginName = in_reg.Name
Application.LogMessage(str(strPluginName) + str(" has been unloaded."),constants.siVerbose)
return true
def QuickThickness_Init( in_ctxt ):
oCmd = in_ctxt.Source
oCmd.Description = ""
oCmd.ReturnValue = true
return true
def QuickThickness_Execute( ):
a = Application
sel = a.Selection
lm = LogMessage
listx = []
lista = []
for x in range(0, sel.Count):
geo = sel(x).activeprimitive.geometry
geoCount = geo.Edges.Count
selcon = sel(x).activeprimitive.ConstructionHistory
if selcon.Find( "extrudenormalop" ) and selcon.Find( "invsrf" ) and selcon.Find( "invertpolygonop" ) and selcon.Find( "extrudecompaxisop" ):
lista.append(sel(x).Name)
else:
listx.append(sel(x).Name)
if listx:
oProgressBar = XSIUIToolkit.ProgressBar
oProgressBar.Maximum = len(listx)
oProgressBar.Caption = "Quick Thickness Process..."
oProgressBar.Visible = True
for y in range(0, len(listx)):
a.SelectObj(listx[y], "", True)
a.SelectGeometryComponents(".poly[*]")
inverseop = a.ApplyTopoOp("Inverse", listx[y], 3, "siPersistentOperation", "")
a.SetValue(str(inverseop)+".inv", True, "")
a.DuplicateMeshComponent("", "siPersistentOperation", "", "", "", "", "", "", "", "", "", "", "", "", True)
a.ApplyTopoOp("InvertPolygon", "", "siUnspecified", "siPersistentOperation", "")
a.ApplyTopoOp("ExtrudeComponentNormal", "", "siUnspecified", "siPersistentOperation", "")
a.SelectObj(listx[y], "", True)
a.SetSelFilter("Border_Edge")
edge = a.SelectAllUsingFilter("Border_Edge", "siCheckComponentVisibility", "", "")
if edge.Count > 0:
a.ApplyTopoOp("WeldEdges", "", "siUnspecified", "siPersistentOperation", "")
a.ActivateObjectSelTool("")
a.SelectObj(listx[y], "", True)
#a.ApplyTopoOp("Inverse", "", 3, "siPersistentOperation", "")
#a.SetValue(".polymsh.invsrf.inv", False, "")
oProgressBar.Increment()
Application.SelectObj(listx)
if lista and listx:
a.AddToSelection(lista)
elif lista:
a.SelectObj(lista)
oProp = XSIFactory.Createobject( 'CustomProperty' )
oProp.Name = "Quick Thickness"
oProp.addparameter2( "Thickness", 5, 1, -100, 100, -5, 5)
oProp.addparameter2( "Subdivs", 2, 0, 0, 100, 0, 5)
oProp.addparameter2( "Inset", 5, 0, -100, 100, -5, 5)
oProp.addparameter2( "Freeze", 5)
oLayout = oProp.PPGLayout
oLayout.AddItem( 'Thickness', "Thickness" , c.siControlNumber)
oLayout.AddItem( 'Subdivs', "Subdivs" , c.siControlNumber)
oLayout.AddItem( 'Inset', "Inset" , c.siControlNumber)
oLayout.AddItem( 'Freeze', "Freeze" , c.siControlButton)
oLayout.Language = "Python"
oLayout.Logic = '''
a = Application
sel = a.Selection
lm = LogMessage
list = []
for x in range(0, sel.Count):
list.append(sel(x))
def Thickness_OnChanged():
for y in range(0, len(list)):
list[y].ActivePrimitive.ConstructionHistory.Find( "extrudenormalop" ).Parameters(1).Value = PPG.Thickness.Value
#if PPG.Thickness.Value < 0:
# list[y].ActivePrimitive.ConstructionHistory.Find("invsrf").Parameters(0).Value = True
#else:
# list[y].ActivePrimitive.ConstructionHistory.Find("invsrf").Parameters(0).Value = False
def Subdivs_OnChanged():
for y in range(0, len(list)):
list[y].ActivePrimitive.ConstructionHistory.Find( "extrudenormalop" ).Parameters(6).Value = PPG.Subdivs.Value
def Inset_OnChanged():
for y in range(0, len(list)):
list[y].ActivePrimitive.ConstructionHistory.Find( "extrudenormalop" ).Parameters(2).Value = PPG.Inset.Value
def Freeze_OnClicked():
a.SelectObj(list, "", True)
a.FreezeModeling("", "", "")
PPG.Close()
'''
if listx or lista:
a.inspectobj( oProp , "", "", 3)
return true
def QuickThickness_Menu_Init( in_ctxt ):
oMenu = in_ctxt.Source
oMenu.AddCommandItem("QuickThickness","QuickThickness")
return true
Thanks one more time for script ! I have 2 minor problemsKolya wrote: ↑18 Oct 2021, 13:10 Hi, place .xsicompound into C:\Users\user_name\Autodesk\Softimage_version\Data\Compounds and restart SoftimageCode: Select all
var s = new ActiveXObject( "XSI.Collection" ); s.AddItems(Selection); var c = Clone(s); for(var i=0, sCount=s.Count; i<sCount; i++){ var op = SIApplyICEOp("MirrorConstraint", c(i), s(i)); }
Users browsing this forum: No registered users and 54 guests