Author Topic: Bricscad: checking for point inside of polyline  (Read 2135 times)

0 Members and 1 Guest are viewing this topic.

Atook

  • Swamp Rat
  • Posts: 1027
  • AKA Tim
Bricscad: checking for point inside of polyline
« on: September 30, 2017, 08:35:56 PM »
Does Bricscad have a similar extension to Autodesks AcMPolygonObj dbx?

On my Autocad implementation, I'm currently using Gile's solution here, and I'm looking to do something similar for Bricscad.

If there isn't a similar library, does Bricscad proved a good way to test for a point being inside of a closed polyline?

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: Bricscad: checking for point inside of polyline
« Reply #1 on: October 02, 2017, 07:05:55 PM »
have a look into the Teigha.Geometry namespace, you may need to create a temporary surface which has the IsOn method.

The Teigha.Geometry namespace has all of the 'primitive' geometry classes used by the graphics system rather than the higher level geometry classes used by the visible database entities.

hth
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

Atook

  • Swamp Rat
  • Posts: 1027
  • AKA Tim
Re: Bricscad: checking for point inside of polyline
« Reply #2 on: October 02, 2017, 07:53:03 PM »
Thanks Mick D. I'll give it a shot.

Is there a good place to read about .NET programming for Bricscad?

Neither the bricsys forums or the Chapoo dev support channel seems very helpful. The swamp seems the place to be (as usual) :)

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: Bricscad: checking for point inside of polyline
« Reply #3 on: October 02, 2017, 11:47:01 PM »
The API for Bricscad is the same as for AutoCAD so what works for one will (should) work for the other just fine apart from a few small edge cases.

With these edge cases I've found that Bricscad handles them the way you would expect it to work but I've had to tweak a few things when using the same code for AutoCAD.

If you need to build for both, a good start is your 'using's to import namespaces. Use an abbreviation for each namespace like the following:

Code - C#: [Select]
  1. // alias' for Bricscad
  2. #if Bricscad
  3. using Teigha.Runtime;
  4. using Teigha.DatabaseServices;
  5. using Bricscad.ApplicationServices;
  6. using Bricscad.EditorInput;
  7. using Bricscad.Runtime;
  8. using _AcRx = Teigha.Runtime;
  9. using _AcAp = Bricscad.ApplicationServices;
  10. using _AcDb = Teigha.DatabaseServices;
  11. using _AcGe = Teigha.Geometry;
  12. using _AcEd = Bricscad.EditorInput;
  13. using _AcGi = Teigha.GraphicsInterface;
  14. using _AcClr = Teigha.Colors;
  15. using _AcWnd = Bricscad.Windows;
  16. using _App = Bricscad;
  17.  
  18. // alias' for AutoCAD
  19. #elif ACAD
  20. using Autodesk.AutoCAD.Runtime;
  21. using Autodesk.AutoCAD.ApplicationServices;
  22. using Autodesk.AutoCAD.DatabaseServices;
  23. using Autodesk.AutoCAD.Geometry;
  24. using Autodesk.AutoCAD.EditorInput;
  25. using Autodesk.AutoCAD.GraphicsInterface;
  26. using Autodesk.AutoCAD.Colors;
  27. using Autodesk.AutoCAD.Windows;
  28. using _AcRx = Autodesk.AutoCAD.Runtime;
  29. using _AcAp = Autodesk.AutoCAD.ApplicationServices;
  30. using _AcDb = Autodesk.AutoCAD.DatabaseServices;
  31. using _AcGe = Autodesk.AutoCAD.Geometry;
  32. using _AcEd = Autodesk.AutoCAD.EditorInput;
  33. using _AcGi = Autodesk.AutoCAD.GraphicsInterface;
  34. using _AcClr = Autodesk.AutoCAD.Colors;
  35. //using _AcWnd = Autodesk.AutoCAD.Windows;
  36. #endif
  37.  

and then you add the "Bricscad" and "ACAD" directives in the 'Build'->'Conditional compilation symbols' in the project properties for each build profile.

"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

Atook

  • Swamp Rat
  • Posts: 1027
  • AKA Tim
Re: Bricscad: checking for point inside of polyline
« Reply #4 on: October 03, 2017, 03:06:46 AM »
Thanks MickD, I'm using the namespaces and the compilation symbols as recommended by you and the Briscad team. Is there a way to have all the classes in a C# project pull the same using statements? Right now I'm chasing the #if statements across every single class in my project.

So far the only 'edge' cases that have given me problems are creating the MPolygons as I mentioned in this post, and creating block previews.

That being said, I've not managed to compile for Briscad yet, I'm sure I'll run into problems once it's up and running in Briscad.

Once I get it up and running the next step will be to autoload it.

Looks like the best way to do this is to create an entry in Computer\HKEY_CURRENT_USER\Software\Bricsys\BricsCAD\V17x64\en_US\Addins as proposed by Kean here?

Thanks again for your input MickD, greatly appreciated.

jmaeding

  • Bull Frog
  • Posts: 304
  • I'm just here for the Shelties.
Re: Bricscad: checking for point inside of polyline
« Reply #5 on: October 03, 2017, 11:24:57 AM »
ATook, be sure to check out Kean Walmsley's blog Through the Interface, and the adesk forums. You will find most of what you need for .net and acad/bcad.

For the loading, what I do is set up the On_doc_load_default.lsp with a netload statement.
That assumes you can do that. If making tools you will be running on systems you cannot control, I would provide a menu that has a .mnl, which is a lisp that loads with the menu. You can put the netload code in there.
The reg stuff works too, but can be tricky to troubleshoot if things are not loading.

aslo, your question about is a point in a pline - if you extend that point into a long vert line, and test if it intersects the pline segs, you can tell if the point was inside by if the point is between the intersection points. You have to think through the cases like point right on the pline, but that is the idea. I did my own line/arc intersection routines, and I recommend doing so as you need control of results at odd cases like things almost intersecting.
James Maeding