Recent Posts

Pages: [1] 2 3 ... 10
1
.NET / Re: Hatch not showing up after creation
« Last post by Kralj_klokan on Today at 06:30:00 PM »
Hi everyone,

The conclusion is that code posted is working fine. When I type the command in the command prompt its working perfectly. As i wished to call the command from a button on a palette i found out that it has to be something that has to do with the palette.
I even tried calling the same code from a modal dialog or simply immediately when initializing the application and everything worked.

The only explanation must that when calling this kind of code from a palette results in errors and is not reliable.
If anyone tries to do the same thing i did i can only suggest that he tries using a modal dialog while creating his plugin since it seems that it's more reliable.

Thanks everyone for your help.
2
CAD General / Where does autocad save the different variable settings?
« Last post by quaziconscience on July 19, 2019, 06:50:02 PM »
Hey all,

Where does autocad store/save the different variable settings? 
3
AutoLISP (Vanilla / Visual) / Re: Angle of Closed polylines elbows
« Last post by MP on July 19, 2019, 02:10:35 PM »
My pleasure; cheers.
4
AutoLISP (Vanilla / Visual) / Re: Angle of Closed polylines elbows
« Last post by Coder on July 19, 2019, 11:14:57 AM »
In addition to Lee’s most excellent guidance you may find this useful in your lisp journey: http://www.afralisp.net/autolisp/tutorials/polyline-bulges-part-1.php ...
Beautiful indeed.  8-)
Thank you for taking the time and post that informative link.
5
.NET / Re: Hatch not showing up after creation
« Last post by Kralj_klokan on July 19, 2019, 11:11:40 AM »
As SendStringToExecute runs asynchronously, you have to also wrap the jig process in the same CommandMethod or another one.

If you do not want to use SendStringToExecute, you are responsible of locking the document (in a using statement) and setting the focus to the editor window before calling the methods.

Thank you for your help.

I think that i now correctly lock the document and set the focus to the dwg. But still if i try to call the code like this
Code - C#: [Select]
  1. hatch.TraceBoundaryAndHatch();
It still does not show the hatch. The exact same code will work if i call it with SendStringToExecute  This is the code i came up with:

Code - C#: [Select]
  1. public void TraceBoundaryAndHatch()
  2.         {
  3.             Document doc = Application.DocumentManager.MdiActiveDocument;
  4.             Database db = doc.Database;
  5.             Editor ed = doc.Editor;
  6.             bool ContinueHatch = true;
  7.  
  8.             using (DocumentLock acLckDoc = doc.LockDocument())
  9.             {
  10.                 Autodesk.AutoCAD.Internal.Utils.SetFocusToDwgView();
  11.                 while (ContinueHatch)
  12.                 {
  13.                     PromptPointResult ppr = ed.GetPoint("\nSelect internal point: ");
  14.                     if (ppr.Status != PromptStatus.OK) ContinueHatch = false;
  15.  
  16.                     if (ContinueHatch)
  17.                     {
  18.                         DBObjectCollection objs = ed.TraceBoundary(ppr.Value, true);
  19.                         if (objs.Count == 0) return;
  20.  
  21.  
  22.                         using (Transaction tr = doc.TransactionManager.StartTransaction())
  23.                         {
  24.                             BlockTable blockTable = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
  25.                             BlockTableRecord MSrecord = tr.GetObject(blockTable[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
  26.  
  27.                             using (Hatch hat = new Hatch())
  28.                             {
  29.                                 MSrecord.AppendEntity(hat);
  30.                                 tr.AddNewlyCreatedDBObject(hat, true);
  31.                                 hat.HatchStyle = HatchStyle.Outer;
  32.                                 hat.SetDatabaseDefaults();
  33.                                 hat.Color = color;
  34.                                 hat.SetHatchPattern(HatchPatternType.PreDefined, "SOLID");
  35.                                 hat.DowngradeOpen();
  36.                                 hat.Associative = true;
  37.                                 foreach (DBObject obj in objs)
  38.                                 {
  39.                                     Curve c = obj as Curve;
  40.                                     if (c != null)
  41.                                     {
  42.                                         ObjectId curveId = MSrecord.AppendEntity(c);
  43.                                         tr.AddNewlyCreatedDBObject(c, true);
  44.                                         hat.AppendLoop(HatchLoopTypes.Default, new ObjectIdCollection() { curveId });
  45.                                     }
  46.                                 }
  47.                             }
  48.  
  49.                             tr.Commit();
  50.                         }
  51.                     }
  52.                 }
  53.             }
  54.         }

Could it be that AutoCAD does some more things while executing a command? Maybe some kind of redraw or regen? If i manually call regen or redraw the hatch still will not show.
The only way it shows is if i try to edit its outer boundary. Or maybe the way i append the loop is not correct? Still i can't explain why the same code works when called as a command with SendStringToExecute() but not if I just call the method from code?.

I can only be grateful for your patience.


6
.NET / Re: Hatch not showing up after creation
« Last post by gile on July 19, 2019, 10:10:55 AM »
As SendStringToExecute runs asynchronously, you have to also wrap the jig process in the same CommandMethod or another one.

If you do not want to use SendStringToExecute, you are responsible of locking the document (in a using statement) and setting the focus to the editor window before calling the methods.
7
AutoLISP (Vanilla / Visual) / Re: Angle of Closed polylines elbows
« Last post by MP on July 19, 2019, 09:52:09 AM »
In addition to Lee’s most excellent guidance you may find this useful in your lisp journey: http://www.afralisp.net/autolisp/tutorials/polyline-bulges-part-1.php ...
8
AutoLISP (Vanilla / Visual) / Re: Angle of Closed polylines elbows
« Last post by Coder on July 19, 2019, 09:27:33 AM »
I got it.  :wink:

Thanks again.
9
AutoLISP (Vanilla / Visual) / Re: Angle of Closed polylines elbows
« Last post by Coder on July 19, 2019, 08:26:49 AM »
Wow that's great.  :wink:

Can you please tell how does atan work and why to multiply with 4.0 and not another decimal number?

Thank you Lee for your kind help.
10
.NET / Re: Hatch not showing up after creation
« Last post by Kralj_klokan on July 19, 2019, 08:25:36 AM »
Hi,

It's a good practice to wrap your method in a CommandMethod and call it with SendStringToExevute() from a modeless dialog (typically a palette set). This way you let AutoCAD taking care of locking the document and setting the focus to the editor.

I have no problem with doing it that way. But what if i want to wait when the command is over to do some more code. Should i listen for a CommandEnded() event or something like that? Let's say i want to have some values updated when i execute this command.
Pages: [1] 2 3 ... 10