What's new

Search results for query: CurrentPart()

  1. stepalibre

    How to access the owner of a parameter in a part through API?

    ...to get the parameters of a plane. This is true for other collections. You can update a parameter by name: part = CurrentPart() aa = part.GetParameter("A1") aa.Value = 100 Is the goal to update a specific plane's parameter by name? Plane -> BasePlatePlane1 -> Parameter -> A1 -> Value -> 2.5...
  2. D

    How to access the owner of a parameter in a part through API?

    ...Equations, Result, Type, Owner, Source, Comment. Iterating through the parameters in the file: The owner value is missing. part = CurrentPart() for i in range(len(part.Parameters)): print(dir(part.Parameters)) [I]['AttachToExcel', 'Comment', 'Equals', 'Equation', 'ExcelCell'...
  3. stepalibre

    AlibreScript Code Assistant - Custom GPT

    ...Angle += AngleIncrement * (math.pi / 180.0) # Convert angle increment to radians for consistent progression # Assuming CurrentPart() and Add3DSketch are part of your CAD API Helix = CurrentPart() PathName = 'Path_Segment_%d' % (Segment + 1) Path = Helix.Add3DSketch(PathName)...
  4. stepalibre

    AlibreScript Code Assistant - Custom GPT

    ...Y = Radius * math.sin(Angle) Z = Pass * HeightIncrement Points.extend([X, Y, Z]) Angle += AngleIncrement Helix = CurrentPart() Path = Helix.Add3DSketch('Path') Path.AddBspline(Points) Version 2: import sys import math Win = Windows() Options = [] Options.append(['Angle...
  5. stepalibre

    Add3DSketch throws COMException with CurrentPart()

    ...I think it's caused by having multiple Alibre Design windows open with the Alibre Script addon enabled. When switching between windows CurrentPart() can fail. To solve this you can use other methods to get the current session when using multiple Alibre Script addon instances. I'm on a Mac...
  6. K

    Access the existing part parameters in the equation editor.

    ...parameter.name and parameter.value... Deleting a parameter isn't possible either... Units.Current = UnitTypes.Millimeters param = CurrentPart() print ('Aktuelles Teil : '), param.Parameters parametername = 'Breite' M = -1 for i in range(len(param.Parameters)): # Für alle...
  7. stepalibre

    Access the existing part parameters in the equation editor.

    To get the parameter objects in CurrentPart() or CurrentAssembly(). param = CurrentPart() param.Parameters The Excel add-in? https://help.alibre.com/articles/#!alibre-help-v27/spreadsheet-driven-designs
  8. NateLiquidGravity

    Configurations Player

    ...Thanks IDSLK try: Enviroment = CurrentAssembly() EnviromentText = 'Assembly ' + str(Enviroment) except: Enviroment = CurrentPart() EnviromentText = 'Part, Name: ' + str(Enviroment) this lets you do things like: if EnviromentText.startswith('Assembly'): print('This is an...
  9. stepalibre

    Add3DSketch throws COMException with CurrentPart()

    I restarted my PC and tried it again and CurrentPart is working again. The other 2 methods worked just fine it was CurrentPart that was crashing. Thanks for checking. Yes importing AlibreScript is for VS Code.
  10. stepalibre

    Add3DSketch throws COMException with CurrentPart()

    I tried it again and now it works. This is strange because the other methods were working fine and CurrentPart() was not. Now it is. There must have been an issue that resolved itself after the restart.
  11. NateLiquidGravity

    Add3DSketch throws COMException with CurrentPart()

    ...methods and properties from both in the same object (unless they happen to be named exactly the same but even then their use and results would be different) There should be no reason that Part() and CurrentPart() are different though. I will have to test on my own machine and write back on that.
  12. stepalibre

    Add3DSketch throws COMException with CurrentPart()

    The solution: import math from AlibreScript import * part = Part(CurrentPart()._Part) sketch3D = part.Add3DSketch('My3DSketch') if sketch3D is None: raise Exception("Failed to create 3D sketch.") sketch3D.StartEditing() # Define start and end points of the line startPoint = [0, 0, 0] #...
  13. stepalibre

    Add3DSketch throws COMException with CurrentPart()

    I have solutions: https://www.alibre.com/forum/index.php?threads/iterating-through-part-sketches.21458/#post-139276 https://www.alibre.com/forum/index.php?search/315520/&q=CurrentPart%28%29&o=date CurrentPart() should be called AlibreScriptSession() or similar.
  14. stepalibre

    AlibreScript Code Assistant - Custom GPT

    ...or code correctness. how to add a chamfer to an edge? import math from AlibreScript import * # Initialize the part session part = CurrentPart() # Assuming you have a part with an edge to chamfer. # The edge can be obtained in various ways, depending on the context. # Here's a generic way...
  15. stepalibre

    Add3DSketch throws COMException with CurrentPart()

    FYI, While debugging the GPT, I noticed issues around Part() vs CurrentPart(). The solution for now is to not use CurrentPart() in the GPT or manually fix it. This creates other issues, being that another window is opened with the new Part(). This is very cumbersome not to mention OpenAI...
  16. stepalibre

    AlibreScript Code Assistant - Custom GPT

    ...without needing cleanup: from AlibreScript import * def create_base_plate_with_holes(): # Initialize a part session part = CurrentPart() # Define dimensions for the base plate and holes plate_length = 100.0 # Length of the base plate plate_width = 50.0 # Width of...
  17. stepalibre

    AlibreScript Programming and Learning with VS Code | AlibreScriptAPIVSCodeDemo

    I would like to share an experimental project for using VS Code to assist in Alibre Script programming and learning. It requires Python programming and VS Code knowledge. I utilize standard Python techniques and VS Code features, no special tools and libraries required. You should install Python...
  18. stepalibre

    Polygon over 24 sides hangs = must kill Alibre in TaskMngr

    ...uses that as the center point for the polygon. import math Diameter = 10 Sides = 5 EDia = Diameter / math.cos(math.pi / Sides) P = CurrentPart() RefAnchor = P.GetPoint("anchor") S = P.AddSketch('Regular_Polygon_60_Sides_Dia_100', P.GetPlane('XY-Plane')) S.AddPolygon(RefAnchor.X...
  19. stepalibre

    Polygon over 24 sides hangs = must kill Alibre in TaskMngr

    ...geometry. This code runs in ~1-2 seconds without sketch relations/constraints: import math Diameter = 100 Sides = 60 EDia = Diameter / math.cos(math.pi / Sides) P = CurrentPart() S = P.AddSketch('Regular_Polygon_60_Sides_Dia_100', P.GetPlane('XY-Plane')) S.AddPolygon(0, 0, EDia, Sides, False)
  20. idslk

    Automatic render a part name from dimentions

    ...a dummy value (here "empty", the dummy is needed to make the property accessable...) - run the following AlibreScript: enviroment = CurrentPart() value_a = enviroment.GetParameter('length').Value value_b = enviroment.GetParameter('width').Value value_c =...
Top