Re: [IronPython] Embedding Question

2006-08-10 Thread Shri Borde
Another alternative is:

ClrModule clr = (ClrModule)engine.Import("clr");
clr.AddReference(typeof(SomeAutoCadType).Assembly);

This is similar to doing 
"engine.LoadAssembly(typeof(SomeAutoCadType).Assembly)", but is more robust 
since it also updates "clr.References". PythonEngine.LoadAssembly should be 
deprecated in favor of ClrModule.AddReference.

Shri

Do you want to help develop Dynamic languages on CLR? 
(http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038)
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Slide
Sent: Thursday, August 10, 2006 3:02 PM
To: Discussion of IronPython
Subject: Re: [IronPython] Embedding Question

There is also an Import method on the PythonEngine object that allows you to 
import stuff programatically as well.

On 8/10/06, Kristof Wagemans <[EMAIL PROTECTED]> wrote:
>
>
>
>
> Isn't engine.LoadAssembly(typeof(SomeAutoCadType).Assembly)
> easier or is this different in some way?
>
>
>
>  
>
>
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Dino Viehland
>  Sent: Thursday 10 August 2006 21:17
>
>  To: Discussion of IronPython
>  Subject: Re: [IronPython] Embedding Question
>
>
>
>
>
>
>
> 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("import
> clr\nclr.AddReference(assembly)");
>
> adr(typeof(SomeAutoCadType).Assembly);
>
>
>
> ___
> users mailing list
> users@lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
>
___
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
___
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Embedding Question

2006-08-10 Thread Slide
There is also an Import method on the PythonEngine object that allows
you to import stuff programatically as well.

On 8/10/06, Kristof Wagemans <[EMAIL PROTECTED]> wrote:
>
>
>
>
> Isn't engine.LoadAssembly(typeof(SomeAutoCadType).Assembly)
> easier or is this different in some way?
>
>
>
>  
>
>
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of
> Dino Viehland
>  Sent: Thursday 10 August 2006 21:17
>
>  To: Discussion of IronPython
>  Subject: Re: [IronPython] Embedding Question
>
>
>
>
>
>
>
> 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("import
> clr\nclr.AddReference(assembly)");
>
> adr(typeof(SomeAutoCadType).Assembly);
>
>
>
> ___
> users mailing list
> users@lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
>
___
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Embedding Question

2006-08-10 Thread Kristof Wagemans








Isn’t engine.LoadAssembly(typeof(SomeAutoCadType).Assembly)
easier or is this different in some way?

 









From:
[EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dino Viehland
Sent: Thursday 10 August 2006
21:17
To: Discussion
 of IronPython
Subject: Re: [IronPython]
Embedding Question



 

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("import
clr\nclr.AddReference(assembly)");

adr(typeof(SomeAutoCadType).Assembly);

 






___
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Embedding Question

2006-08-10 Thread Tim Riley
Thanks Dino. I had figured that out.On 8/10/06, Dino Viehland <[EMAIL PROTECTED]> wrote:













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("import clr\nclr.AddReference(assembly)");

adr(typeof(SomeAutoCadType).Assembly);

 

 



From:
[EMAIL PROTECTED] [mailto:
[EMAIL PROTECTED]] On
Behalf Of Tim Riley
Sent: Thursday, August 10, 2006 12:10 PM
To: Discussion of IronPython
Subject: Re: [IronPython] Embedding Question



 

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("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
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 <[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
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?


Regards,
Tim Riley








___
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com



 








___
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com





 







___users mailing listusers@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
___
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Embedding Question

2006-08-10 Thread Dino Viehland








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("import clr\nclr.AddReference(assembly)");

adr(typeof(SomeAutoCadType).Assembly);

 

 



From:
[EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Tim Riley
Sent: Thursday, August 10, 2006 12:10 PM
To: Discussion of IronPython
Subject: Re: [IronPython] Embedding Question



 

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("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
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 <[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
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?


Regards,
Tim Riley








___
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com



 








___
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com





 






___
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Embedding Question

2006-08-10 Thread 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("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
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 <[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
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?


Regards,
Tim Riley








___
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com





 







___users mailing listusers@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
___
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Embedding Question

2006-08-10 Thread Dino Viehland








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(“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
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 <[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
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?


Regards,
Tim Riley








___
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com





 






___
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Embedding Question

2006-08-10 Thread 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. 
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 <[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
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?


Regards,
Tim Riley







___users mailing listusers@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
___
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Embedding Question

2006-08-10 Thread Dino Viehland








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
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?


Regards,
Tim Riley






___
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com