[IronPython] Problems translating from C#
seawolf2913 at gmail.com
Fri Mar 5 04:17:58 CET 2010
I've used Python for a while and I understand the basic concepts of OOP, but
I'm new to .NET and C#. I'm trying to automate a 3D CAD package called
Alibre so I can generate 300+ assemblies and export them to an industry
standard format. I've been looking through their C# sample code for two days
now and I understand most of it, I can translate a good portion of it,
(IronPython in Action arrived three days ago :), but there is on line in
particular that I can't figure out.
Here's a snippet of the C# example file. I can post the whole thing if
needed. //# starts comments I've added in.
private void btnBrowse_Click(object sender, EventArgs e)
IADSession objSession; //Holds Alibre Session
IADDesignSession designSession; //Holds Alibre Design
IADPhysicalProperties designProps; //Holds Physical
OpenFileDialog ofd = new OpenFileDialog(); //# Opens a dialog
box so you can enter the name of an existing part file.
ofd.Title = "Select File";
ofd.Filter = "Alibre Part|*.AD_PRT";
if (ofd.ShowDialog() == DialogResult.OK)
txtFilePath.Text = ofd.FileName;
if (rootObj == null) //# rootObj is the Root Object for
controlling Alibre Design
OpenAlibre(); //Call to method which checks to see if
there is running instance of Alibre Design
//# This method, defined further
down in the file, attaches to a running instance of the program, or starts a
//# In either case, rootObj is
created and attached to it.
objSession = rootObj.OpenFile(txtFilePath.Text); //#
Creates an instance of IADSession from the rootObj
if (objSession.SessionType == ADObjectSubType.AD_PART) //#
As long as the Session is attached to a part...
//# THIS IS THE LINE I CAN'T TRANSLATE!!!
(IADDesignSession)objSession; //Set Design Session Object to
be the Session you opened
//# I think it's creating an instance of IADDesignSession
based on the objSession (see code line below) and I can't figure out how to
//# designSession = objSession obviously leaves me two
references to the same Session Object.
//# I've done dir(objSession) and I don't see a method to
create a DesignSession instance.
//# Any ideas??
designSession.PhysicalProperties(ADAccuracySetting.AD_HIGH); //Set Design
Properties object with the Physical Properties of the Part
Thanks in Advance
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ironpython-users