Entity intersections
All intersection points of two entities into caller arrays (CadGetInterPoints).
// Entity-entity intersection points. static void feat_interpts() { samp_clear(); int l = CadAddLine(g_hDwg, -80, -25, 0, 80, 25, 0); int c = CadAddCircle(g_hDwg, 0, 0, 0, 40); double xs[8], ys[8]; int n = 0; CadGetInterPoints(g_hDwg, l, c, xs, ys, &n, 8); for (int i = 0; i < n; ++i) { int m = CadAddCircle(g_hDwg, xs[i], ys[i], 0, 2); CadEntityPutColor(m, CAD_COLOR_RED); } CadUpdate(g_hDwg); samp_zoom_ext(); wchar_t s[120]; swprintf(s, 120, L"CadGetInterPoints: %d intersection(s) marked in red", n); set_status(s); }
11: // Intersections begin CadPurge(FhDwg, CAD_CLEAR_ENTITIES); l := CadAddLine(FhDwg, -80, -25, 0, 80, 25, 0); c := CadAddCircle(FhDwg, 0, 0, 0, 40); n := 0; CadGetInterPoints(FhDwg, l, c, @xs[0], @ys[0], n, 8); for i := 0 to n - 1 do begin m := CadAddCircle(FhDwg, xs[i], ys[i], 0, 2); CadEntityPutColor(m, CAD_COLOR_RED); end; CadUpdate(FhDwg); CadExecute(FhDwg, FCadHwnd, CAD_CMD_ZOOM_EXT); StatusBar.SimpleText := Format('CadGetInterPoints: %d intersection(s) marked in red', [n]); end;
private void FeatInterPts() { SampleClear(); var l = YuCadApi.CadAddLine(_hDwg, -80, -25, 0, 80, 25, 0); var c = YuCadApi.CadAddCircle(_hDwg, 0, 0, 0, 40); var xs = new double[8]; var ys = new double[8]; YuCadApi.CadGetInterPoints(_hDwg, l, c, xs, ys, out var n, 8); for (var i = 0; i < n; ++i) { var m = YuCadApi.CadAddCircle(_hDwg, xs[i], ys[i], 0, 2); YuCadApi.CadEntityPutColor(m, YuCadApi.CAD_COLOR_RED); } YuCadApi.CadUpdate(_hDwg); SampleZoomExt(); SetStatus($"CadGetInterPoints: {n} intersection(s) marked in red"); }
This code is extracted verbatim from the shipped demo hosts (
examples/cpp, examples/delphi, examples/csharp) — run the matching menu item there to see it live.