Last active
February 17, 2026 13:22
-
-
Save stephensmitchell/b23a0158963c4fd1d10481ff8f0107dd to your computer and use it in GitHub Desktop.
AlibreObjectModel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void Main() | |
| { | |
| Console.WriteLine("=== AlibreObjectModel Version Info ==="); | |
| Console.WriteLine($"Assembly Version: {AlibreObjectModel.Version.AssemblyVersion}"); | |
| Console.WriteLine($"File Version: {AlibreObjectModel.Version.FileVersion}"); | |
| Console.WriteLine($"Informational Version: {AlibreObjectModel.Version.InformationalVersion}"); | |
| Console.WriteLine($"Build Timestamp: {AlibreObjectModel.Version.InternalBuildDateTimeStampVersion}"); | |
| Console.WriteLine(); | |
| Console.WriteLine("=== SIMPLE EXTRUSION TEST ==="); | |
| var root = AlibreObjectModel.Alibre.Attach(); | |
| PartSession part = root.ActiveSession.AsPart(); | |
| Console.WriteLine($"Part: {part.Name}"); | |
| IADDesignPlane xyPlane = part.DesignPlanes.Item(0) as IADDesignPlane; | |
| Console.WriteLine($"Plane: {xyPlane.Name}"); | |
| Console.WriteLine("Creating sketch..."); | |
| IADSketch sketch = part.Sketches.AddSketch(null, xyPlane, "TestProfile-0"); | |
| sketch.BeginChange(); | |
| sketch.Figures.AddRectangle(-50, -30, 50, 30); | |
| sketch.EndChange(); | |
| var result = sketch.ValidateForFeature(); | |
| Console.WriteLine($"Sketch: IsClosed={result.IsClosed}, IsFullyConstrained={result.IsFullyConstrained}"); | |
| Console.WriteLine("Creating extrusion..."); | |
| IADExtrusionFeature extrusion = part.Features.AddExtrudedBoss( | |
| sketch, | |
| 40.0, // depth | |
| ADPartFeatureEndCondition.AD_TO_DEPTH, | |
| null, null, 0, | |
| ADDirectionType.AD_ALONG_NORMAL, | |
| null, null, false, | |
| 0, false, | |
| "TestBox", | |
| null, null | |
| ); | |
| Console.WriteLine($"Extrusion created: {extrusion.Name}"); | |
| Console.WriteLine($"Bodies: {part.Bodies.Count}"); | |
| if (part.Bodies.Count > 0) | |
| { | |
| var body = (IADBody)part.Bodies.Item(0); | |
| } | |
| Console.WriteLine("=== SUCCESS ==="); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void Main() | |
| { | |
| Console.WriteLine("=== AlibreObjectModel Version Info ==="); | |
| Console.WriteLine($"Assembly Version: {AlibreObjectModel.Version.AssemblyVersion}"); | |
| Console.WriteLine($"File Version: {AlibreObjectModel.Version.FileVersion}"); | |
| Console.WriteLine($"Informational Version: {AlibreObjectModel.Version.InformationalVersion}"); | |
| Console.WriteLine($"Build Timestamp: {AlibreObjectModel.Version.InternalBuildDateTimeStampVersion}"); | |
| Console.WriteLine(); | |
| Console.WriteLine("=== SIMPLE EXTRUSION TEST ==="); | |
| var root = AlibreObjectModel.Alibre.Attach(); | |
| IADPartSession part = root.ActiveSession.AsPart(); | |
| Console.WriteLine($"Part: {((IADSession)part).Name}"); | |
| IADDesignPlane xyPlane = part.DesignPlanes.Item(0) as IADDesignPlane; | |
| Console.WriteLine($"Plane: {xyPlane.Name}"); | |
| Console.WriteLine("Creating sketch..."); | |
| IADSketch sketch = part.Sketches.AddSketch(null, xyPlane, "TestProfile"); | |
| sketch.BeginChange(); | |
| sketch.Figures.AddRectangle(-50, -30, 50, 30); | |
| sketch.EndChange(); | |
| var result = sketch.ValidateForFeature(); | |
| Console.WriteLine($"Sketch: IsClosed={result.IsClosed}, IsFullyConstrained={result.IsFullyConstrained}"); | |
| Console.WriteLine("Creating extrusion..."); | |
| IADExtrusionFeature extrusion = part.Features.AddExtrudedBoss( | |
| sketch, | |
| 40.0, // depth | |
| ADPartFeatureEndCondition.AD_TO_DEPTH, | |
| null, null, 0, | |
| ADDirectionType.AD_ALONG_NORMAL, | |
| null, null, false, | |
| 0, false, | |
| "TestBox", | |
| null, null | |
| ); | |
| Console.WriteLine($"Extrusion created: {extrusion.Name}"); | |
| Console.WriteLine($"Bodies: {part.Bodies.Count}"); | |
| if (part.Bodies.Count > 0) | |
| { | |
| var body = (IADBody)part.Bodies.Item(0); | |
| } | |
| Console.WriteLine("=== SUCCESS ==="); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| test2.py - Python (PythonNet) port of test2.cs | |
| Creates a simple extruded box in the active Alibre Design part session. | |
| """ | |
| import os | |
| import sys | |
| if getattr(sys, "frozen", False): | |
| _bundle_dir = sys._MEIPASS | |
| sys.path.append(_bundle_dir) | |
| else: | |
| _base = os.path.dirname(os.path.abspath(__file__)) | |
| _linqpad_dir = os.path.dirname(_base) # ..\LINQPad | |
| _objmodel_dir = os.path.join( | |
| _linqpad_dir, "..", "src", "AlibreObjectModel", "bin", "Release", "net8.0" | |
| ) | |
| sys.path.append(_linqpad_dir) | |
| sys.path.append(_objmodel_dir) | |
| from pythonnet import load | |
| load("coreclr") | |
| import clr | |
| clr.AddReference("AlibreX") | |
| clr.AddReference("AlibreObjectModel") | |
| from AlibreX import ADPartFeatureEndCondition, ADDirectionType | |
| from AlibreObjectModel import Alibre, Version, SketchValidationExtensions | |
| from System import Int32 | |
| def main(): | |
| print("=== AlibreObjectModel Version Info ===") | |
| print(f"Assembly Version: {Version.AssemblyVersion}") | |
| print(f"File Version: {Version.FileVersion}") | |
| print(f"Informational Version: {Version.InformationalVersion}") | |
| print(f"Build Timestamp: {Version.InternalBuildDateTimeStampVersion}") | |
| print() | |
| print("=== SIMPLE EXTRUSION TEST ===") | |
| root = Alibre.Attach() | |
| part = root.ActiveSession.AsPart() | |
| print(f"Part: {part.Name}") | |
| xy_plane = part.DesignPlanes.Item(Int32(0)) | |
| print(f"Plane: {xy_plane.Name}") | |
| print("Creating sketch...") | |
| sketch = part.Sketches.AddSketch(None, xy_plane, "TestProfile-0") | |
| sketch.BeginChange() | |
| sketch.Figures.AddRectangle(-50, -30, 50, 30) | |
| sketch.EndChange() | |
| result = SketchValidationExtensions.ValidateForFeature(sketch) | |
| print(f"Sketch: IsClosed={result.IsClosed}, IsFullyConstrained={result.IsFullyConstrained}") | |
| print("Creating extrusion...") | |
| extrusion = part.Features.AddExtrudedBoss( | |
| sketch, | |
| 40.0, # depth | |
| ADPartFeatureEndCondition.AD_TO_DEPTH, | |
| None, | |
| None, | |
| 0, | |
| ADDirectionType.AD_ALONG_NORMAL, | |
| None, | |
| None, | |
| False, | |
| 0, | |
| False, | |
| "TestBox", | |
| None, | |
| None, | |
| ) | |
| print(f"Extrusion created: {extrusion.Name}") | |
| print(f"Bodies: {part.Bodies.Count}") | |
| if part.Bodies.Count > 0: | |
| body = part.Bodies.Item(Int32(0)) | |
| print("=== SUCCESS ===") | |
| if __name__ == "__main__": | |
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #:package AlibreObjectModel@1.0.0 | |
| #:property TargetFramework=net48 | |
| #:property PlatformTarget=x64 | |
| #:property Prefer32Bit=false | |
| #:property PublishAot=false | |
| using System; | |
| using System.Runtime.InteropServices; | |
| using AlibreObjectModel; | |
| using AlibreX; | |
| // SimpleExtrusionTest - Minimal extrusion test | |
| // Open an empty part in Alibre Design before running | |
| Console.WriteLine("=== AlibreObjectModel Version Info ==="); | |
| Console.WriteLine($"Assembly Version: {AlibreObjectModel.Version.AssemblyVersion}"); | |
| Console.WriteLine($"File Version: {AlibreObjectModel.Version.FileVersion}"); | |
| Console.WriteLine($"Informational Version: {AlibreObjectModel.Version.InformationalVersion}"); | |
| Console.WriteLine($"Build Timestamp: {AlibreObjectModel.Version.InternalBuildDateTimeStampVersion}"); | |
| Console.WriteLine(); | |
| Console.WriteLine("=== SIMPLE EXTRUSION TEST ==="); | |
| var root = AlibreObjectModel.Alibre.Attach(); | |
| IADPartSession part = root.ActiveSession.AsPart(); | |
| Console.WriteLine($"Part: {((IADSession)part).Name}"); | |
| IADDesignPlane xyPlane = part.DesignPlanes.Item(0) as IADDesignPlane; | |
| Console.WriteLine($"Plane: {xyPlane.Name}"); | |
| Console.WriteLine("Creating sketch..."); | |
| IADSketch sketch = part.Sketches.AddSketch(null, xyPlane, "TestProfile"); | |
| sketch.BeginChange(); | |
| sketch.Figures.AddRectangle(-50, -30, 50, 30); | |
| sketch.EndChange(); | |
| var result = sketch.ValidateForFeature(); | |
| Console.WriteLine($"Sketch: IsClosed={result.IsClosed}, IsFullyConstrained={result.IsFullyConstrained}"); | |
| Console.WriteLine("Creating extrusion..."); | |
| IADExtrusionFeature extrusion = part.Features.AddExtrudedBoss( | |
| sketch, | |
| 40.0, // depth | |
| ADPartFeatureEndCondition.AD_TO_DEPTH, | |
| null, null, 0, | |
| ADDirectionType.AD_ALONG_NORMAL, | |
| null, null, false, | |
| 0, false, | |
| "TestBox", | |
| null, null | |
| ); | |
| Console.WriteLine($"Extrusion created: {extrusion.Name}"); | |
| Console.WriteLine($"Bodies: {part.Bodies.Count}"); | |
| if (part.Bodies.Count > 0) | |
| { | |
| var body = (IADBody)part.Bodies.Item(0); | |
| } | |
| Console.WriteLine("=== SUCCESS ==="); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Development version:
