.NET

Reply
*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 11 of 24 (524 Views)

Re: How to open autocad.exe in C# , PLEASE HELP!

02-07-2012 02:45 AM in reply to: Leimhu

Try attached code it I rewrote it completely

I added some other things take a look at

the additional functions

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 12 of 24 (508 Views)

Re: How to open autocad.exe in C# , PLEASE HELP!

02-07-2012 10:11 PM in reply to: Leimhu

I wan't to do your homework sorry

In the attached file all is enough for

the basic operations

you have to read some books

about C# reference for more

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Contributor
Leimhu
Posts: 11
Registered: ‎02-05-2012
Message 13 of 24 (507 Views)

Re: How to open autocad.exe in C# , PLEASE HELP!

02-07-2012 10:34 PM in reply to: Hallex

:smileyembarrassed: Dear Hallex, Thanks very much for your patience andexcellent codes

I am reading some articles and books, I am sorry to cost you much time:smileytongue:

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 14 of 24 (505 Views)

Re: How to open autocad.exe in C# , PLEASE HELP!

02-07-2012 11:32 PM in reply to: Leimhu

You're welcome

Just a hint:

Don't forget to rewrite drawLineInObject function

easier yet to use double[] as start and end points as

arguments

Something like:

{code}

public static object DrawLine (object oBlock, double[] p1, double[] p2, string layer)

{

// ...  the rest portion of your code is goes here.....

return oLine;

}{code}

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Contributor
Leimhu
Posts: 11
Registered: ‎02-05-2012
Message 15 of 24 (486 Views)

Re: How to open autocad.exe in C# , PLEASE HELP!

02-08-2012 08:46 PM in reply to: Hallex

Dear Hallex:

I read your code and test in Win7 with .net2008 cad2010, runs very well ~

but in winXP .net2008 cad2008, error happens

it says cannot find the following files:

at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)

at System.Diagnostics.Process.Start()

at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)

at System.Diagnostics.Process.Start(String fileName)

at AcadTestExe.ReflectionCommands.TestACAD(String fname) in F:........

at AcadTestExe.Form1.button1 Click(Object sender. EventArgs e) in F:.......

 

Dear Hallex, should I add some libraries in winXP?

I am a little confused,  

what language do you think is fit for me to learn cad devlopping? 

ObjectARX, or VBA, or visual Lisp, or C# ? 

can you introduce some reference book for me ?

right now I am more familiar with C#, C++ and matlab

 

Thanks for your patience and incredible codes~~~

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 16 of 24 (480 Views)

Re: How to open autocad.exe in C# , PLEASE HELP!

02-08-2012 10:37 PM in reply to: Leimhu

On the quick glance it may occurs by User Permission

See here for more:

http://msdn.microsoft.com/en-us/library/system.diagnostics.process.process(v=vs.80).aspx

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Contributor
Leimhu
Posts: 11
Registered: ‎02-05-2012
Message 17 of 24 (460 Views)

Re: How to open autocad.exe in C# , PLEASE HELP!

02-09-2012 08:52 PM in reply to: Hallex

Dear Hallex:

I test your code in anther computers

It runs well in WinXP and Win7 64bit, cad2004, 2007, 2008, 2010

you are genius, Hallex

I read many articles

and never see cad C# code without any libraries

your defined AcadApp and AcadDoc as Object 

Is it the reason that can runs well in different OS and CAD ?

 

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 18 of 24 (454 Views)

Re: How to open autocad.exe in C# , PLEASE HELP!

02-09-2012 11:31 PM in reply to: Leimhu

Hi,

There is no magic in my crappy codes

just well-known runtime methods nothing else

Please see here for more:

 

http://msdn.microsoft.com/en-us/library/system.reflection(v=vs.80).aspx

 

Hey, cease to praise me, I same stupid, as my gray-haired @$$ :smileyhappy:

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Contributor
Leimhu
Posts: 11
Registered: ‎02-05-2012
Message 19 of 24 (451 Views)

Re: How to open autocad.exe in C# , PLEASE HELP!

02-10-2012 04:47 AM in reply to: Hallex

Dear Hallex:

I never found cad C# code as powerful as yours which even need not dll or com

so I admire you :smileytongue:

I am reading cad VBA now, and take a look at the MSDN web link you gave me

I know your code use some VBA Method, just like AddLine, Open...

My question is :

how do you know the parameters of using vba method?

For example: object AcDoc = AcadDocs.GetType().InvokeMember("Open", BindingFlags.InvokeMethod, null, AcadDocs, args, null);

you define args: args[0] = fname;(file path and name)  args[1] = false;(can write dwg)

I saw in vba is :ThisDrawing.Application.Documents.Open "c:\1.dwg"

how do you know need fname together with false?

where can I find the rules?

all in C# library reference, reflection???

 

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 20 of 24 (447 Views)

Re: How to open autocad.exe in C# , PLEASE HELP!

02-10-2012 06:09 AM in reply to: Leimhu

No, all these arguments in AutoCAD Help file

That is a lot of work to digg it from there

Say, open VBA editor in AutoCAD by Alt+F11

Then in console add dummy Sub say:

{code}

Public sub Test()

type Open in here, then select a word Open

by double click on them and press F1

See then all arguments in the Help file

End sub

 {code}

Hint:

To convert any arguments to numeric values:

Open 'Immediate Window' in same editor and type here

any of AutoCad's constants preceded with question mark like this:

 

?acActiveViewPort

 or

?acSelectionSetAll

or

??acselectionSetCrossingPolygon

or

?acMiddleCenter ETC, ETC

 

Then press Enter

You should see a numeric equivalent of this constant

 in the same window next line below

So nothing smart it's just a lot of work, you have to digg deeper yourself

 

 

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.