Author Topic: Prevent hatch overlapping while hatching by PickPoint  (Read 2380 times)

0 Members and 1 Guest are viewing this topic.

Kralj_klokan

  • Newt
  • Posts: 23
Prevent hatch overlapping while hatching by PickPoint
« on: August 21, 2019, 06:57:28 AM »
Hi,

I 'm creating a AutoCAD plugin where i  implemented a pickpoint hatch. The problem is that i would like to prevent the user from clicking twice on the same area and hatching the same area twice.
Is there any way i could check if under some point is a hatch located and stop the method? Or is it possible to create an overrule where a click would be disabled if an hatch is located under the cursor?

I 'd be happy with any suggestions.

Thank you in advance

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8659
  • AKA Daniel
Re: Prevent hatch overlapping while hatching by PickPoint
« Reply #1 on: August 21, 2019, 08:35:15 PM »
maybe use a point monitor?

Kralj_klokan

  • Newt
  • Posts: 23
Re: Prevent hatch overlapping while hatching by PickPoint
« Reply #2 on: August 22, 2019, 04:25:36 PM »
Could you provide some example possibly?

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8659
  • AKA Daniel
Re: Prevent hatch overlapping while hatching by PickPoint
« Reply #3 on: August 22, 2019, 09:17:13 PM »

n.yuan

  • Bull Frog
  • Posts: 348
Re: Prevent hatch overlapping while hatching by PickPoint
« Reply #4 on: August 23, 2019, 09:46:42 AM »
Hi,

I 'm creating a AutoCAD plugin where i  implemented a pickpoint hatch. The problem is that i would like to prevent the user from clicking twice on the same area and hatching the same area twice.
Is there any way i could check if under some point is a hatch located and stop the method? Or is it possible to create an overrule where a click would be disabled if an hatch is located under the cursor?

I 'd be happy with any suggestions.

Thank you in advance

You might want to show your code, or explain/describe the workflow of your process of "pickpoint hatch", so that one can see why you need to prevent the same area to be picked more than once and how to do it.

Le't me imagine what "pickpoint hatch" would be:

1. you ask user to pick a point in a area, which is enclosed by one or more entities;
2. After a point is picked, you call Editor.TraceBoundary() to return 1 boundary entity (when the argument for detecting island is false). At this point you have a hatch-able area;
3. You either go ahead to hatch this area; then repeat the "pickpoint" again; or you can keep the boundary in a collection and ask user to do another round of "pickpoint", and only hatch them all at the end.

As you can see, after each point picking, you either have Hatch object available (you created it), or you have a boundary entity available. Of course after multiple picking, you would keep them in a collection. So, whenever user picks again, you can do calculation to determine if the point is inside already picked area (either inside a Hatch, or a boundary entity). If the point is double pick, you simply not hatch it or not keep the boundary entity (for later hatching) and prompt user of the double picking. You can even use Point_Monitor to track the mouse move, so that whenever the cursor moves, you do the "if is inside" calculation, and if yes, you show warning tool tip or even change cursor type as visual hint. BUt in most cases, I'd not bother using Point_Monitor handling for this: it could be expensive operation, if for every tiny mouse move, calling Editor.TraceBoundary(), then calculating against multiple previously created Hatches/boundary entities to decide "if-is-inside" could be quite demanding.

Anyway, it is as simple as validating a newly picked point against one or more previously picked area or areas (determine if it is inside) before accepting the picked point.