3D Design

3D Design

Wizard Error on SpaceClaim

    • valentin miguel
      Subscriber

      Hello, 

      I am working on Wizard for SpaceClape with ATC Builder.
      I like to use the function " Measure Helper" but I fail.
      I use it for 2 different missions.
      A first for finding "X overall".

       

      It's important to know, for instance, function "xOverall = MeasureHelper. BodyExtrema (selection). X" works perfectly in scripting in SpaceClaim but  return  an error in wizard Script.
      I have one error, I am looking, but don't find a solution.

      I have created a little script for tests of the solution if you have one.

      Python code, name is "main.py" :
       
      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
          #---------les 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

          #---------------------------------- strat 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])
         
          #----------------------------------- strat 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])
          #-------------------------------------strat 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])
          xOverall = SpaceClaim.Api.V22.Scripting.Helpers.MeasureHelper.BodyExtrema(selection).X

                 

          #sele = PartSelection.Create(GetRootPart())
          #sele = GetRootPart().Bodies[0]




          part = None
       
       
      Error is :
      Error when invoking function 'GenerateBF'.
      Traceback (most recent call last): 
      File "D:\stage - Copie\BBS\1213\BBS\main.py", line 87, in GenerateBF 
      StandardError: Exception has been thrown by the target of an invocation.
      Traceback (most recent call last): 
      File "D:\stage - Copie\BBS\1213\BBS\main.py", line 87, in GenerateBF 
      TypeError: expected IDesignBody, got DesignBody
       
      If you can help me, thanks
       
    • Aniket
      Ansys Employee

      What error do you get when using the command in wizard?

      -Aniket

      How to access Ansys help links

      Guidelines for Posting on Ansys Learning Forum

      • valentin miguel
        Subscriber

         

        Hi, 

        thanks for your time, error comes from the complete code, the lines are not good. 

        Here is the error. 

        Error when invoking function 'GenerateBF'.
        Traceback (most recent call last): 
        File "F:\stage - Copie\BBS\0612\BBS\main.py", line 399, in GenerateBF 
        File "F:\stage - Copie\BBS\0612\BBS\main.py", line 120, in CreateDie 
        File "F:\stage - Copie\BBS\0612\BBS\main.py", line 106, in takedim 
        StandardError: Exception has been thrown by the target of an invocation.
        Traceback (most recent call last): 
        File "F:\stage - Copie\BBS\0612\BBS\main.py", line 399, in GenerateBF 
        File "F:\stage - Copie\BBS\0612\BBS\main.py", line 120, in CreateDie 
        File "F:\stage - Copie\BBS\0612\BBS\main.py", line 106, in takedim 
        AttributeError: 'type' object has no attribute 'BodyExtrema'

         

         

         

    • Aniket
      Ansys Employee

      Can you paste what code is there at these lines?

      -Aniket

      How to access Ansys help links

      Guidelines for Posting on Ansys Learning Forum

      • valentin miguel
        Subscriber

        Code lign 106 is : 

        xOverall = MeasureHelper.BodyExtrema(se).X
         
        lines of code 399, 120 call the "takedim" function which contains the error.
        And error is : 
        Error when invoking function 'GenerateBF'.
        Traceback (most recent call last): 
        File "F:\stage - Copie\BBS\0612\BBS\main.py", line 399, in GenerateBF 
        File "F:\stage - Copie\BBS\0612\BBS\main.py", line 120, in CreateDie 
        File "F:\stage - Copie\BBS\0612\BBS\main.py", line 106, in takedim 
        StandardError: Exception has been thrown by the target of an invocation.
        Traceback (most recent call last): 
        File "F:\stage - Copie\BBS\0612\BBS\main.py", line 399, in GenerateBF 
        File "F:\stage - Copie\BBS\0612\BBS\main.py", line 120, in CreateDie 
        File "F:\stage - Copie\BBS\0612\BBS\main.py", line 106, in takedim 
        AttributeError: 'type' object has no attribute 'BodyExtrema'
         
        -Miguel
Viewing 2 reply threads
  • You must be logged in to reply to this topic.