I am trying this with Tony`s CommandLine Class
CommandLine.Command("_PLINE", "20.0,0.0", "30.0,30.0", "15.0,0.0", "7.0,7.0");
But after this line AutoCAD continues to prompt me for the next POINT.
This wont work too :
CommandLine.Command("_PLINE", "20.0,0.0", "30.0,30.0", "15.0,0.0", "7.0,7.0", " "); <- blank space here
I dont know a command to cancel this because "space" does not work.
Does anybody know a command to cancel the polyline command?
I am using autoCAD 2008 and 2007.
Solved! Go to Solution.
CommandLine.Command("_PLINE", "20.0,0.0", "30.0,30.0", "15.0,0.0", "7.0,7.0", " "); <- This will not work
CommandLine.Command("_PLINE", "20.0,0.0", "30.0,30.0", "15.0,0.0", "7.0,7.0", ""); <- This works and terminates the command. I suppose this will work with every other command.
Sorry for answering my own question, but when I got a problem I just cant continue before solving it.
Can you tell me why you use a command string to draw a pline.
Pleaze look at this document link. It's from the AutoCAD.NET Developers Guide.
This sample demonstrates how te create a pline from points stored in a collection.
You can create a method wich passes a collection of points and a pline will be created for you.
Yes, you are right. The reason is that I want to make some short cuts in my code. There are a lot of procedures that I rewrite whenever possible with the command line. I try different techniques. The first is only .NET and the other is command line with event handlers. Sometimes 4-5 lines for command line equals to 20-30 lines of .NET code. I just want to know both ways
Thanks for the link too
Because the calss that I am using is a .NET class. That is Tonys clas. It is faster sometimes to make one line of a command() rather than sever lines with transaction and so forth with code. For example the XLINE in 2007 is coded different in 2008.
By using CommandLine I have the same command working for both versions without any change in the code.
// This works in 2008 will not even compile in 2007
// because of the following error :
// Error 1 'Autodesk.AutoCAD.DatabaseServices.Xline' does not contain a definition for 'SecondPoint'
XLine hhline = new Xline();
hhline.SecondPoint = getPointResult2.Value;
I find it useful to create my graphical stuff with commandLine and collect the objectIds through an event handler and when I finish I just collect the Ids from a class ObjecIdCollection and do whatever is needed.
I am grateful to Tony Tanzillo Here is his class.
My suggestion :
As soon as possible stop using Command from net.
Thats like having a lamborghini and using a goat to pull it around. !!
class keyThumper<T> : Lazy<T>; another Swamper
If you tell me the way to create polylines, then join them, then extrude them to solid in 6 lines of .NET code I will be convinced. I use this as a shortcut. I dont say that it is perfect. It is a way to write things fast at first place.
I can't create it in 6 lines of code. But i can create a function or a method which you can provide with a collection of points. Create an in memory polyline. Make an extrusion from that in memory pline and add the extruded element to the drawing.
Yes this function or method consist of more lines of code but its one function so when you need to change it it's in one place.
And writing your six lines of code over and over again for each of your elements will be more lines of code.
Look at this link
In this sample the create 2 in memory circle and then turn them to a region.
And if you combine some functions in from this sample:
you only need to create something to supply the function with your coordinates to create your in memory plines.