valentin miguel
Subscriber

I use recorded script but i modifided it for create a wizard.

My code :

import System
import clr
import sys
import os
import math
import zipimport
import __builtin__
import commands
import random
"""
'SpaceClaim': , , 
'Commands': ,
 'System': ,
 
"""
 
clr.AddReference("SpaceClaim.Api.V22")
clr.AddReference("SpaceClaim.Api.V22.Scripting")
 
#clr.AddReference("AnsysSCPlugin.22.2")
#from SpaceClaim.Api.V22 import Geometry
#from SpaceClaim.Api.V22.Scripting import Commands,Helpers,Selection
#from AnsysSCPlugin import *
from SpaceClaim.Api.V22 import *
from SpaceClaim.Api.V22.Scripting import *
from System import *
 
part = None
 
def oninit(context):
    return
 
def GenerateBF(step):
    global part
    win = Window.ActiveWindow
    context = win.ActiveContext
    part = context.ActivePart
 
    if part==None:
        win = Window.ActiveWindow
        context = win.ActiveContext
        part = context.ActivePart.Master
    body = part.Bodies
 
 
    #verifier le measurehelper
    #--------- selection--------------
 
    ExtAPI.Log.WriteWarning("TENTATIVE 2")
    #body = GetRootPart().Bodies[0]
    #se = Selection.Create(body)
    #se = Selection.Create(GetRootPart().Bodies[0])
    #se = PowerSelection.Bodies.AllSolidBodies(PowerSelectOptions(False))
    #se = Selection.SelectAll()
    #se =  SpaceClaim.Api.V22.Scripting.Selection.ISelection.FilterByVisible
 
    #---------------------------------- attempt 1
 
    #X = Direction.DirX
    #Y = Direction.DirY
    #Z = Direction.DirZ
    #XMIN = se.GetExtremePoint(-X,Y,Z)
    #XMAX =se.GetExtremePoint(X,Y,Z)
    #YMIN = se.GetExtremePoint(-Y,Z,X)
    #YMAX =se.GetExtremePoint(Y,Z,X)    
    #ZMIN = se.GetExtremePoint(-Z,X,Y)
    #ZMAX =se.GetExtremePoint(Z,X,Y)
    #xOverall = abs(XMAX[0]-XMIN[0])
    #yOverall = abs(YMAX[1]-YMIN[1])
    #zOverall = abs(ZMAX[2]-ZMIN[2])
    
    #----------------------------------- attempt 2 
    #bb = Selection.Create(GetRootPart().Bodies[0])
    #MAX = bb.BoundingBox.MaxCorner
    ##MIN = bb.BoundingBox.MinCorner
    #xOverall = abs(MAX[0]-MIN[0])
    #yOverall = abs(MAX[1]-MIN[1])
    #zOverall = abs(MAX[2]-MIN[2])
    #-------------------------------------attempt 3 
 
    #centre = SpaceClaim.Api.V22.Scripting.Helpers.MeasureHelper.GetCenterOfMass(se)
    #rX = Direction.DirX
    #ms = MeasureHelper.BodyExtrema(se).X
    #bb = SpaceClaim.Api.V22.Scripting.Selection.ISelection.AddToActive(Selection.Create(GetRootPart().Bodies[0]))
    #rr  = SpaceClaim.Api.V22.Scripting.Helpers.MeasureHelper()
    #cvd=rr.BodyExtrema(bb)
    selection = SpaceClaim.Api.V22.Scripting.Selection.BodySelection.Create(GetRootPart().Bodies[0])
    #selection = SpaceClaim.Api.V22.Scripting.Selection.ISelection.SetActive(SpaceClaim.Api.V22.Scripting.Selection.ISelection)
    #selection = SpaceClaim.Api.V22.Scripting.Selection. 
    xOverall = SpaceClaim.Api.V22.Scripting.Helpers.MeasureHelper.BodyExtrema(selection).X
 
            
 
    #sele = PartSelection.Create(GetRootPart())
    #sele = GetRootPart().Bodies[0]
 
 
 
 
    part = None

 

There are error on "xOverall=SpaceClaim.Api.V22.Scripting.Helpers.MeasureHelper.BodyExtrema(selection).X"

"selection" is not right, we need an "ISelection" type and we have the "Selection" type. I can't use the "MeasureHelper.BodyExtrema()" function, when I use it in Wizard.

Thank you