.NET

Reply
Contributor
mabe2k11
Posts: 24
Registered: ‎03-14-2006
Message 1 of 9 (485 Views)

Fillet between lines with dotnet

485 Views, 8 Replies
04-18-2006 02:45 PM
Hello!

Is it possible to create the fillet between two lines or the lines of a polyline with dotnet?
In my application the user should select a polyline and the program creates the section of a metal sheet with the coordinates of the selected polyline. But to draw the section i need to create a lot of fillets.

I hope someone can help me. Unfortunately it is very difficult to find some manuals about dotnet-programming in AutoCAD.
*Tony Tanzillo
Message 2 of 9 (485 Views)

Re: Fillet between lines with dotnet

04-18-2006 03:29 PM in reply to: mabe2k11
Filleting must be done manually via the API methods, or you
can use a more sensable/rational approach, and just drive the
FILLET command via the command line.

See the code that I posted in this newsgroup for an easy
to use wrapper for the command line, without the having to
deal with the asynchronous sendStringToExecute() nonsense.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

wrote in message news:5146485@discussion.autodesk.com...
Hello!

Is it possible to create the fillet between two lines or the lines of a polyline with dotnet?
In my application the user should select a polyline and the program creates the section of a metal sheet with the coordinates of the selected polyline. But to draw the section i need to create a lot of fillets.

I hope someone can help me. Unfortunately it is very difficult to find some manuals about dotnet-programming in AutoCAD.
Contributor
mabe2k11
Posts: 24
Registered: ‎03-14-2006
Message 3 of 9 (485 Views)

Re: Fillet between lines with dotnet

04-20-2006 12:46 AM in reply to: mabe2k11
Thank You!

I think the command-method is the better way. The API-method seems to be to difficult.

I looked at this discussion group and i found something.
Now i can run a command string to draw a line for example:
Document doc = Application.DocumentManager.MdiActiveDocument;
doc.SendStringToExecute("_line 100 100 ", false, false, false);

But how can i draw a fillet. I have to select the two lines, after running the "_fillet" command. Can I work with the entities which the user has already selected in my dotnet program?
Or is it necessary to learn LISP first to do something like drawing a fillet? Then it could useful to look in a LISP-forum for the answer.
*James Maeding
Message 4 of 9 (485 Views)

Re: Fillet between lines with dotnet

04-20-2006 01:07 PM in reply to: mabe2k11
you mean you are doing .net and don't know lisp?
Either way, lisp would only use the command line to run the fillet command.
I guess it all comes down to having .net make a lisp callable selection set...not sure on that

mabe2k <>
|>Thank You!
|>
|>I think the command-method is the better way. The API-method seems to be to difficult.
|>
|>I looked at this discussion group and i found something.
|>Now i can run a command string to draw a line for example:
|> Document doc = Application.DocumentManager.MdiActiveDocument;
|> doc.SendStringToExecute("_line 100 100 ", false, false, false);
|>
|>But how can i draw a fillet. I have to select the two lines, after running the "_fillet" command. Can I work with the entities which the user has already selected in my dotnet program?
|>Or is it necessary to learn LISP first to do something like drawing a fillet? Then it could useful to look in a LISP-forum for the answer.
James Maeding
Civil Engineer and Programmer
jmaeding - athunsaker - com
Distinguished Contributor
NathTay
Posts: 1,691
Registered: ‎12-15-2003
Message 5 of 9 (485 Views)

Re: Fillet between lines with dotnet

04-20-2006 04:02 PM in reply to: mabe2k11
You can use the following to pass the entity where objEnt is the entity.

" (handent " & Chr(34) & objEnt.Handle & Chr(34) & ") "

I don't see a connection between doing .NET and knowing lisp but this example shows where it is helpful.

Regards - Nathan
Distinguished Contributor
NathTay
Posts: 1,691
Registered: ‎12-15-2003
Message 6 of 9 (485 Views)

Re: Fillet between lines with dotnet

04-20-2006 04:04 PM in reply to: mabe2k11
Sorry objEnt.Handle is the ActiveX Method. I don't know the .NET equivalent off hand.
Contributor
mabe2k11
Posts: 24
Registered: ‎03-14-2006
Message 7 of 9 (485 Views)

Re: Fillet between lines with dotnet

04-22-2006 12:41 PM in reply to: mabe2k11
Tony, I found the following code posted by you. I changed it to fillet the last polyline. But when I run TestInvokeLisp in AutoCAD i don't get a result. Nothing happens and I do not really understand what your code does, so it's very difficult to find the bug. Perhaps you can help me.

Thank you.

// Here ist the code I have

using System;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.EditorInput;
using System.Runtime.InteropServices;
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;


namespace AcadTools
{
public class AcedInvokeSample
{
public const int RTLONG = 5010; // adscodes.h
public const int RTSTR = 5005;

public const int RTNORM = 5100;

public AcedInvokeSample()
{
}

[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl)]
extern static private int acedInvoke(IntPtr args, out IntPtr result);

public static ResultBuffer InvokeLisp(ResultBuffer args, ref int stat)
{
IntPtr rb = IntPtr.Zero;
stat = acedInvoke(args.UnmanagedObject, out rb);
if (stat == (int)PromptStatus.OK && rb != IntPtr.Zero)
return (ResultBuffer)
DisposableWrapper.Create(typeof(ResultBuffer), rb, true);
return null;
}

[CommandMethod("TestInvokeLisp")]
public static void TestInvokeLisp()
{
ResultBuffer args = new ResultBuffer();
int stat = 0;

args.Add(new TypedValue(RTSTR, "_fillet"));
args.Add(new TypedValue(RTSTR, "p"));
args.Add(new TypedValue(RTSTR, "_last"));

ResultBuffer res = InvokeLisp(args, ref stat);
if (stat == RTNORM && res != null)
{
PrintResbuf(res);
res.Dispose();
}
}
}
}
Distinguished Contributor
Alexander Rivilis
Posts: 303
Registered: ‎09-26-2004
Message 8 of 9 (485 Views)

Re: Fillet between lines with dotnet

04-23-2006 11:05 AM in reply to: mabe2k11
Look at this topic: http://discussion.autodesk.com/thread.jspa?messageID=4858935 and find CommandTest() function by Tony.
With help of this function you can execute AutoCAD command, such as fillet.
InvokeLisp() is only for calling lisp/arx-function from .NET-application, but not for execute AutoCAD command directly.
Contributor
mabe2k11
Posts: 24
Registered: ‎03-14-2006
Message 9 of 9 (485 Views)

Re: Fillet between lines with dotnet

04-24-2006 10:29 AM in reply to: mabe2k11
Thanks to all of you. I got it ;-)

I attached the C#-File which draws the section of a metal sheet. It's not finished jet (error-handling is not good), but i think it's a good start for people who have the same problem.

Info to MetalSheet.cs (I had to rename it for uploading): Run MetalSheet in ACAD and select a polyline. You get five new lines which look like a metalsheet.
Need installation help?

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