What's new

Is there a suitable Python IDE that can be used to step through scripts?

NateLiquidGravity

Alibre Super User
I don't know if such a thing is possible since Alibre Script is built in scripting engine. The best suggestion I've got is to print out information after each step to see where it is. I use a separate function for debug printing so I can turn it off at the top of the script without effecting other prints.

Code:
debugging = 1

def debugPrint(string):
    global debugging
    If debugging:
        print(string)
    return

print('Hello World')
# do something
debugPrint('That something worked')
# do something else
debugPrint('That something worked too')
print('Done')
 

otrotabi

Member
The standard python debugger is pdb. Here´s a little tutorial on how this should work on a regular python runtime.


Basically it should allow you to do what you want, if it worked within Alibre Script.

If you run the following script it should allow you to get some inputs before stopping at the line that says "import pdb; pdb.set_trace()". If you run this script you will notice it will actually import pdb without complaining, but neither stopping there, I am afraid. I will ask support if this is possible somehow.

# Demonstrates requesting values from the user then creating a part
# with those values

print 'Enter geometry: 1:3/8", 2:1/2"'
Geometria = float(Read())
if Geometria == 1 :
print 'Selected geometry is 25.4x22 mm diámetro 3/8"'
DistX = 22
DistY = 25.4
Diametro = 9.52;

if Geometria == 2 :
print 'Selected geometry is 38.1x33 mm diámetro 1/2"'
DistX = 33
DistY = 38.1
Diametro = 12.7;

print 'Enter tube height'
Hileras = float(Read())
if Hileras < 2:
sys.exit('El numero de hileras en altura debe ser al menos de 2')

print 'Entre tube depth'
Filas = float(Read())


print 'Entre fpi'
EC = float(Read())
if EC < 0.1:
sys.exit('EC must be at least 0.1 mm')


print 'Generacion de aletado de aluminio de geometría %f con medidas %f mm x %f mm x %f mm...' % (Geometria,Filas*DistX, Hileras*DistY, EC)
print 'Las filas en profundidad son %f y las hileras son %f' % (Filas, Hileras)

Aletado = Part('Aletado')

# El Aletado se dibuja sobre el plano XY, la chapa base está apoyada ahí.
#it should stop right here and let you step through the rest of the code

import pdb; pdb.set_trace()
FinX = Filas*DistX
FinY = Hileras*DistY


Profile = Aletado.AddSketch('Profile', Aletado.GetPlane('XY-Plane'))
Profile.AddRectangle(0, 0, FinX, FinY, False)
Aletado.AddExtrudeBoss('Aletado', Profile, EC, False)

# Genero el sketch
Agujero = Aletado.AddSketch('Extrusion', Aletado.GetPlane('XY-Plane'))

# Dibujo los agujeros
#j1 va barriendo las filas en profundidad e i1 las hileras en altura
j1 = 1
while j1 < (Filas + 1) :
i1 = 1
while i1 < (Hileras + 1) :
if j1 % 2 != 0 :
Agujero.AddCircle((DistX/2+DistX*(j1-1)), (DistY/4+(i1-1)*DistY), Diametro, False)
else :
Agujero.AddCircle((DistX/2+DistX*(j1-1)), (DistY*3/4+(i1-1)*DistY), Diametro, False)
i1 = i1 + 1
j1 = j1 + 1

# Genero la extrusión
Aletado.AddExtrudeCut('Agujero',Agujero,EC,False)
 

otrotabi

Member
Code:
 # Demonstrates requesting values from the user then creating a part
  # with those values


  print 'Enter geometry: 1:3/8", 2:1/2"'
  Geometria = float(Read())
  if Geometria == 1 :
    print 'Selected geometry is 25.4x22 mm diámetro 3/8"'
    DistX = 22
    DistY = 25.4
    Diametro = 9.52;

  if Geometria == 2 :   
    print 'Selected geometry is 38.1x33 mm diámetro 1/2"'   
    DistX = 33
    DistY = 38.1
    Diametro = 12.7;

  print 'Enter tube height'
  Hileras = float(Read())
  if Hileras < 2:
    sys.exit('El numero de hileras en altura debe ser al menos de 2')

  print 'Entre tube depth'
  Filas = float(Read())


  print 'Entre fpi'
  EC = float(Read())
  if EC < 0.1:
    sys.exit('EC must be at least 0.1 mm')
  
        
  print 'Generacion de aletado de aluminio de geometría %f con medidas %f mm x %f mm x %f mm...' % (Geometria,Filas*DistX, Hileras*DistY, EC)
  print 'Las filas en profundidad son %f y las hileras son %f' % (Filas, Hileras)

  Aletado = Part('Aletado')

  # El Aletado se dibuja sobre el plano XY, la chapa base está apoyada ahí.

  import pdb; pdb.set_trace()
  FinX = Filas*DistX
  FinY = Hileras*DistY


  Profile = Aletado.AddSketch('Profile', Aletado.GetPlane('XY-Plane'))
  Profile.AddRectangle(0, 0, FinX, FinY, False)
  Aletado.AddExtrudeBoss('Aletado', Profile, EC, False)

  # Genero el sketch
  Agujero = Aletado.AddSketch('Extrusion', Aletado.GetPlane('XY-Plane'))

  # Dibujo los agujeros
  #j1 va barriendo las filas en profundidad e i1 las hileras en altura
  j1 = 1
  while j1 < (Filas + 1) :
    i1 = 1
    while i1 < (Hileras + 1) :
      if j1 % 2 != 0 :
         Agujero.AddCircle((DistX/2+DistX*(j1-1)), (DistY/4+(i1-1)*DistY), Diametro, False)
      else :
         Agujero.AddCircle((DistX/2+DistX*(j1-1)), (DistY*3/4+(i1-1)*DistY), Diametro, False)
      i1 = i1 + 1
    j1 = j1 + 1

  # Genero la extrusión
  Aletado.AddExtrudeCut('Agujero',Agujero,EC,False)
 
Top