[IronPython] Embedding Question
dinov at exchange.microsoft.com
Thu Aug 10 21:04:59 CEST 2006
You can get the assembly object from an AutoCAD type: typeof(Foo).Assembly. From there you just need to have one helper which will register this in the engine, so you could do:
delegate void AddReference(object assembly);
AddReference adr = engine.CreateMethod<AddReference>("clr.AddReference(assembly)");
and then from there you should be able to import any of the AutoCAD namespaces from any of your modules.
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Tim Riley
Sent: Thursday, August 10, 2006 11:40 AM
To: Discussion of IronPython
Subject: Re: [IronPython] Embedding Question
What I'm trying to do is sort of weird so let me see if I can elaborate further. I am embedding IronPython in a .NET assembly that will later be loaded into AutoCAD. AutoCAD has their own two .NET assemblies that must be referenced, " acmgd.dll" and "acdbmgd.dll". These two assemblies are always loaded while AutoCAD is running so their location isn't really a concern when creating a C# .dll. However when I want to modify AutoCAD entities from within my IP scripts I must first load the assemblies from file and path which is a problem because the file and path are different with each different version of AutoCAD.
For example their path in my AutoCAD Mechanical 2005 is 'C:\Program Files\Autodesk\Acadm 2005' but with regular AutoCAD it would be 'C:\Program Files\Autodesk\Acad 2005'. There are so many different variations that this path could be that it would be a big deal to try/except load them all from some sort of init script.
So basically I'm looking to pass a non-GAC assembly reference from my C# project to my IP project.
Note: I'm fine with the import statements.
On 8/10/06, Dino Viehland <dinov at exchange.microsoft.com<mailto:dinov at exchange.microsoft.com>> wrote:
Adding references updates the entire engine, it's not local to just the current module. So once you have added a reference you just need to import the namespace into any given module.
Were you also trying to avoid the import statements?
From: users-bounces at lists.ironpython.com<mailto:users-bounces at lists.ironpython.com> [mailto: users-bounces at lists.ironpython.com<mailto:users-bounces at lists.ironpython.com>] On Behalf Of Tim Riley
Sent: Thursday, August 10, 2006 11:02 AM
To: Discussion of IronPython
Subject: [IronPython] Embedding Question
If I have an embedded project can I automatically make .NET assemblies referenced in the project available to my python scripts? For example I have two assemblies(not in the GAC) that I have referenced in my project. I would like them always available to all python files run from this program without having to do the import clr, clr.AddReferenceToFileAndPath('blah') stuff in the beginning of each file. Is this possible?
users mailing list
users at lists.ironpython.com<mailto:users at lists.ironpython.com>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ironpython-users