<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"Segoe UI";
        panose-1:2 11 5 2 4 2 4 2 2 3;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {mso-style-builtin:yes;
        margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        mso-style-builtin:yes;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        mso-style-builtin:yes;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-style-builtin:yes;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-builtin:yes;
        mso-style-link:"Balloon Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.gmailquote
        {mso-style-name:gmail_quote;}
span.e
        {mso-style-name:e;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Cool, looks like I was only close though </span><span
style='font-size:11.0pt;font-family:Wingdings;color:#1F497D'>J</span><span
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> 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 1<sup>st</sup> 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:<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p><span style='font-size:11.0pt;color:#1F497D'>delegate void
AddReference(object assembly);</span><o:p></o:p></p>
<p><span style='font-size:11.0pt;color:#1F497D'>AddReference adr =
engine.CreateMethod<AddReference>("import clr\nclr.AddReference(assembly)");</span><o:p></o:p></p>
<p><span style='font-size:11.0pt;color:#1F497D'>adr(typeof(SomeAutoCadType).Assembly);</span><o:p></o:p></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>
<p class=MsoNormal><b><span style='font-size:9.0pt;font-family:"Segoe UI","sans-serif"'>From:</span></b><span
style='font-size:9.0pt;font-family:"Segoe UI","sans-serif"'>
users-bounces@lists.ironpython.com [mailto:users-bounces@lists.ironpython.com] <b>On
Behalf Of </b>Tim Riley<br>
<b>Sent:</b> Thursday, August 10, 2006 12:10 PM<br>
<b>To:</b> Discussion of IronPython<br>
<b>Subject:</b> Re: [IronPython] Embedding Question<o:p></o:p></span></p>
</div>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal style='margin-bottom:12.0pt'>That's exactly what I needed.
Thank you Dino.<o:p></o:p></p>
<div>
<p class=MsoNormal><span class=gmailquote>On 8/10/06, <b>Dino Viehland</b> <<a
href="mailto:dinov@exchange.microsoft.com">dinov@exchange.microsoft.com</a>
> wrote:</span><o:p></o:p></p>
<div>
<div>
<div>
<p><span style='font-size:11.0pt;color:#1F497D'>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:</span><o:p></o:p></p>
<p><span style='font-size:11.0pt;color:#1F497D'> </span><o:p></o:p></p>
<p><span style='font-size:11.0pt;color:#1F497D'>delegate void
AddReference(object assembly);</span><o:p></o:p></p>
<p><span style='font-size:11.0pt;color:#1F497D'>AddReference adr =
engine.CreateMethod<AddReference>("clr.AddReference(assembly)");</span><o:p></o:p></p>
<p><span style='font-size:11.0pt;color:#1F497D'>adr.AddReference(typeof(SomeAutoCadType).Assembly);</span><o:p></o:p></p>
<p><span style='font-size:11.0pt;color:#1F497D'> </span><o:p></o:p></p>
<p><span style='font-size:11.0pt;color:#1F497D'>and then from there you should
be able to import any of the AutoCAD namespaces from any of your modules.
</span><o:p></o:p></p>
<p><span style='font-size:11.0pt;color:#1F497D'> </span><o:p></o:p></p>
<div style='border:none;border-top:solid windowtext 1.0pt;padding:3.0pt 0in 0in 0in;
border-color:-moz-use-text-color -moz-use-text-color'>
<p><b><span style='font-size:9.0pt'>From:</span></b><span style='font-size:
9.0pt'> <a href="mailto:users-bounces@lists.ironpython.com" target="_blank">users-bounces@lists.ironpython.com
</a>[mailto:<a href="mailto:users-bounces@lists.ironpython.com" target="_blank">users-bounces@lists.ironpython.com</a>]
<b>On Behalf Of </b>Tim Riley<br>
<b>Sent:</b> Thursday, August 10, 2006 11:40 AM<br>
<b>To:</b> Discussion of IronPython<br>
<b>Subject:</b> Re: [IronPython] Embedding Question</span><o:p></o:p></p>
</div>
</div>
<div>
<p> <o:p></o:p></p>
<p style='margin-bottom:12.0pt'>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. <br>
<br>
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. <br>
<br>
So basically I'm looking to pass a non-GAC assembly reference from my C#
project to my IP project.<br>
<br>
<br>
Note: I'm fine with the import statements.<o:p></o:p></p>
<div>
<p>On 8/10/06, <b>Dino Viehland</b> <<a
href="mailto:dinov@exchange.microsoft.com" target="_blank">dinov@exchange.microsoft.com</a>>
wrote:<o:p></o:p></p>
<div>
<div>
<div>
<p><span style='font-size:11.0pt;color:#1F497D'>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. </span><o:p></o:p></p>
<p><span style='font-size:11.0pt;color:#1F497D'> </span><o:p></o:p></p>
<p><span style='font-size:11.0pt;color:#1F497D'>Were you also trying to avoid
the import statements?</span><o:p></o:p></p>
<p><span style='font-size:11.0pt;color:#1F497D'> </span><o:p></o:p></p>
<div style='border:none;border-top:solid windowtext 1.0pt;padding:3.0pt 0in 0in 0in;
border-color:-moz-use-text-color'>
<p><b><span style='font-size:9.0pt'>From:</span></b><span style='font-size:
9.0pt'> <a href="mailto:users-bounces@lists.ironpython.com" target="_blank">users-bounces@lists.ironpython.com
</a>[mailto:<a href="mailto:users-bounces@lists.ironpython.com" target="_blank">
users-bounces@lists.ironpython.com</a>] <b>On Behalf Of </b>Tim Riley<br>
<b>Sent:</b> Thursday, August 10, 2006 11:02 AM<br>
<b>To:</b> Discussion of IronPython<br>
<b>Subject:</b> [IronPython] Embedding Question</span><o:p></o:p></p>
</div>
</div>
<div>
<p> <o:p></o:p></p>
<p>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?<br>
<br>
<br>
Regards,<br>
Tim Riley<o:p></o:p></p>
</div>
</div>
</div>
<p style='margin-bottom:12.0pt'><br>
_______________________________________________<br>
users mailing list<br>
<a href="mailto:users@lists.ironpython.com" target="_blank">users@lists.ironpython.com</a><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com"
target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><o:p></o:p></p>
</div>
<p> <o:p></o:p></p>
</div>
</div>
</div>
<p class=MsoNormal style='margin-bottom:12.0pt'><br>
_______________________________________________<br>
users mailing list<br>
<a href="mailto:users@lists.ironpython.com">users@lists.ironpython.com</a><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com"
target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
<br>
<o:p></o:p></p>
</div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
</body>
</html>