Cool, looks like I was only close though J You
may have already imported clr into the default module, but just for the record
for those who haven’t you’ll need an import clr there. I just realized I
forgot it the 1st time, and I had a redundant “AddReference” in the
delegate call. I’m assuming you just fixed all that up, but just in case
anyone else needs to do something like this, here’s the correct code: delegate void
AddReference(object assembly); AddReference adr =
engine.CreateMethod<AddReference>("import clr\nclr.AddReference(assembly)"); adr(typeof(SomeAutoCadType).Assembly); From:
[EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Tim Riley That's exactly what I needed.
Thank you Dino. On 8/10/06, Dino Viehland <[EMAIL PROTECTED]
> wrote: 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)"); adr.AddReference(typeof(SomeAutoCadType).Assembly); and then from there you should
be able to import any of the AutoCAD namespaces from any of your modules.
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
On Behalf Of Tim Riley 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. On 8/10/06, Dino Viehland <[EMAIL PROTECTED]>
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: [EMAIL PROTECTED]
[mailto:
[EMAIL PROTECTED]] On Behalf Of Tim Riley 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@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com