.NET

Reply
Valued Contributor
dynamicscope
Posts: 95
Registered: ‎04-04-2012
Message 1 of 6 (294 Views)
Accepted Solution

Lines to Closed Polylines to Spline

294 Views, 5 Replies
08-01-2012 02:43 AM

I am trying to do something complicated.

 

It will be similar to the following command sequence. (AutoCAD 2010)

 

pe (pedit)

m  (multi select)

all (select all)

y (convert to polylines)

0 (set fuzzy 0)

j (join)

(done)

s (spline)

(done)

c (close)

(done)

(done)

 

But instead of "select all", I want to select the entities in the certain layer (this layer will only contain line entities)

I do not think SendStringToExcute() method can do such filtered selection in the middle of command sequence.

 

So I tried to look for a managed class method that does the "pedit" command. (No clue yet.)

 

So I am asking for your help.

 

Is there way to do such work (with C# ObjectARX 2010)?

It would be appreciated if someone can give me some code snippet.

 

Regards,

Here is a quick sample how to use CommandLine.cs to join:

 

 [CommandMethod("JoinLayer","JL", CommandFlags.UsePickSet)]
public static void Test()
{
Database db = HostApplicationServices.WorkingDatabase;
Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
string layer = ed.GetString("\nEnter layer name: ").StringResult;
string ctab= Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("ctab").ToString();
using (Transaction tr = db.TransactionManager.StartTransaction())
{
PromptSelectionOptions pso = new PromptSelectionOptions();
pso.MessageForRemoval = "\nNothing selected";
pso.MessageForAdding = "\nSelect lines and/or arcs only:";
TypedValue[] tvs = new TypedValue[] { new TypedValue(0, "line,arc"), new TypedValue(8, layer), new TypedValue(410, ctab) };
PromptSelectionResult pres = ed.SelectAll(new SelectionFilter(tvs));
if (pres.Status != PromptStatus.OK) return;
SelectionSet ss = pres.Value;
int res = CommandLine.Command ("._PEDIT", "_m", "_p", "", "_y", "_join", "", "");
ed.Regen();
tr.Commit();
}
}

 Change to your suit

 

~'J'~

 

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 2 of 6 (286 Views)

Re: Lines to Closed Polylines to Spline

08-01-2012 03:55 AM in reply to: dynamicscope

Try to search for CommandLine.cs written by Tony Tanzillo

 

~'J'~

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Valued Contributor
dynamicscope
Posts: 95
Registered: ‎04-04-2012
Message 3 of 6 (281 Views)

Re: Lines to Closed Polylines to Spline

08-01-2012 04:47 AM in reply to: Hallex

Thx for you reply.

 

It seems like Tony's CommandLine.cs is easy-to-use method for SendStringToExecute().

It still does not let me to do filtered selection (or quick selection) in the middle of my command sequence. :smileysad:

 

Is there one line command for filtered selection or quick selection? (without the option dialogue. when I type "filter" or "qselect" a dialogue pops-up)

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 4 of 6 (275 Views)

Re: Lines to Closed Polylines to Spline

08-01-2012 05:35 AM in reply to: dynamicscope

Here is a quick sample how to use CommandLine.cs to join:

 

       [CommandMethod("JoinLayer","JL", CommandFlags.UsePickSet)]
                          public static void Test()
                          {
                              Database db =  HostApplicationServices.WorkingDatabase;
                              Editor ed =    Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
                              string layer = ed.GetString("\nEnter layer name: ").StringResult;
                 string ctab= Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("ctab").ToString();
                              using (Transaction tr =  db.TransactionManager.StartTransaction())
                              {
                                  PromptSelectionOptions pso = new    PromptSelectionOptions();
                                  pso.MessageForRemoval = "\nNothing selected";
                                  pso.MessageForAdding = "\nSelect lines and/or arcs only:";
                                  TypedValue[] tvs = new TypedValue[] { new TypedValue(0, "line,arc"), new TypedValue(8, layer), new TypedValue(410, ctab) };
                                  PromptSelectionResult pres =   ed.SelectAll(new SelectionFilter(tvs));
                                  if (pres.Status != PromptStatus.OK) return;
                                  SelectionSet ss = pres.Value;
                                  int res = CommandLine.Command  ("._PEDIT", "_m", "_p", "", "_y", "_join", "", "");
                                  ed.Regen();
                                  tr.Commit();
                              }
                          }

 Change to your suit

 

~'J'~

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Valued Contributor
dynamicscope
Posts: 95
Registered: ‎04-04-2012
Message 5 of 6 (255 Views)

Re: Lines to Closed Polylines to Spline

08-01-2012 10:49 PM in reply to: Hallex

Ah ha~!!

 

select -> p

 

does the trick I need~!! =)

 

You are always awesome.

Thank you very much.

 

Sincerely,

 

Jake

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

Re: Lines to Closed Polylines to Spline

08-02-2012 05:17 AM in reply to: dynamicscope

You're welcome, Jake

Thanks to Tony Tanzillo :smileyhappy:

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

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