Sambo Posted November 22, 2022 Author Posted November 22, 2022 The above post has now been updated with the new code. I believe it fixes all the bugs. 1 Quote
mhupp Posted November 22, 2022 Posted November 22, 2022 Nice work @Sambo I Working on something should have it posted tonight. 1 Quote
mhupp Posted November 22, 2022 Posted November 22, 2022 (edited) This is a bit different than the lisp ronjonp linked. instead of degrees it uses a minimum length to generate points. It will always divide an arc into 5 equal segments or if the arc can be divided more then 5 by the minimum distance the higher division will be used. the larger outline went from 52 vertices to 656. see example. Apparently you can test for bluge with visual lisp (seen in lisp ronjonp linked). So it make the code a lot simpler. no longer have to explode the polyline. Again thank you @Sambo for pointing out the errors my earlier lisp was making. ;;----------------------------------------------------------------------------;; ;; ssget "WP" doesn't work well with polylines with arcs. This fixes it. (defun selectinside (ent / poly v i ii x bulge seg lst) (setq poly (vlax-ename->vla-object ent) v (vlax-curve-getEndParam poly) i 0 x 3 ;x = how often you want a point along arc ) (while (< i v) (if (/= 0 (abs (vlax-invoke poly 'GetBulge i))) ;pulled from lisp ronjonp linked (progn (setq ii 0) (if (>= (setq seg (fix (/ (- (vlax-curve-getDistAtParam poly (1+ i)) (vlax-curve-getDistAtParam poly i)) x))) 5) (repeat seg (setq lst (cons (vlax-Curve-GetPointAtParam poly (+ i ii)) lst)) (setq ii (+ (/ 1.0 seg) ii)) ) (repeat 5 (setq lst (cons (vlax-Curve-GetPointAtParam poly (+ i ii)) lst)) (setq ii (+ 0.20 ii)) ) ) ) (setq lst (cons (vlax-Curve-GetPointAtParam poly i) lst)) ) (setq i (1+ i)) ) (if (not (member (setq end (vlax-curve-getEndPoint poly)) lst)) (setq lst (cons end lst)) ) (setq SS1 (ssget "_WP" lst)) (setq SS2 (ssget "_CP" lst)) ) ;;----------------------------------------------------------------------------;; ;; entmake polyline for checking points created. ;; (make-poly pnt-lst t) ;closed polyline ;; (make-poly pnt-lst nil) ;open polyline (defun make-poly (pts closed) (entmake (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 90 (length pts)) ;number of vertices (cons 70 (if closed 1 0)) ) (mapcar '(lambda (x) (cons 10 x)) pts) ) ) ) selectinside.dxf Edited November 22, 2022 by mhupp 1 Quote
Sambo Posted November 23, 2022 Author Posted November 23, 2022 (edited) Thanks. This lisp works great! Found another bug though. It seems selection sets don't work with a list that has duplicate vertices and these have not been removed. Example lst data below where points 6 and 7 from the end of the list are duplicate. (((322535.0 5.84308e+06 0.0) (322517.0 5.84308e+06 0.0) (322515.0 5.84306e+06 0.0) (322523.0 5.84306e+06 0.0) (322523.0 5.84306e+06 0.0) (322528.0 5.84306e+06 0.0) (322528.0 5.84306e+06 0.0) (322533.0 5.84306e+06 0.0) (322536.0 5.84306e+06 0.0) (322529.0 5.843e+06 0.0) (322522.0 5.84299e+06 0.0) (322563.0 5.84299e+06 0.0) (322560.0 5.84299e+06 0.0) (322561.0 5.843e+06 0.0) (322564.0 5.84303e+06 0.0) (322624.0 5.84303e+06 0.0) (322640.0 5.84302e+06 0.0) (322643.0 5.84305e+06 0.0) (322647.0 5.84306e+06 0.0) (322651.0 5.84306e+06 0.0) (322653.0 5.84307e+06 0.0) (322648.0 5.84307e+06 0.0) (322646.0 5.84308e+06 0.0) (322652.0 5.84313e+06 0.0) (322655.0 5.84314e+06 0.0) (322660.0 5.84314e+06 0.0) (322662.0 5.84315e+06 0.0) (322657.0 5.84315e+06 0.0) (322654.0 5.84316e+06 0.0) (322661.0 5.84321e+06 0.0) (322664.0 5.84322e+06 0.0) (322707.0 5.84321e+06 0.0) (322710.0 5.84323e+06 0.0) (322713.0 5.84327e+06 0.0) (322626.0 5.84328e+06 0.0) (322588.0 5.84328e+06 0.0) (322589.0 5.84329e+06 0.0) (322575.0 5.84329e+06 0.0) (322570.0 5.84329e+06 0.0) (322568.0 5.84328e+06 0.0) (322574.0 5.84328e+06 0.0) (322571.0 5.84327e+06 0.0) (322567.0 5.84326e+06 0.0) (322560.0 5.84325e+06 0.0) (322558.0 5.84325e+06 0.0) (322557.0 5.84325e+06 0.0) (322555.0 5.84323e+06 0.0) (322555.0 5.84323e+06 0.0) (322548.0 5.84316e+06 0.0) (322544.0 5.84316e+06 0.0) (322542.0 5.84314e+06 0.0) (322545.0 5.84314e+06 0.0) (322538.0 5.84308e+06 0.0))) Test.dwg Edited November 23, 2022 by Sambo Quote
mhupp Posted November 23, 2022 Posted November 23, 2022 Duplicate points don't cause an error in BricsCAD with ssget. Maybe overkill the polyline to remove duplicate vertices? Quote
Sambo Posted November 23, 2022 Author Posted November 23, 2022 (edited) 1 hour ago, mhupp said: Duplicate points don't cause an error in BricsCAD with ssget. Maybe overkill the polyline to remove duplicate vertices? Overkill will remove arcs within the poly at times, i just ran a function to delete the duplicate points from the list before creating the selection set. I also found this issue: No idea why its doing that on certain polys but i just removed nil from the list before creating the selection set too. My best guess would be multiple duplicate vertices in a row but it didn't seem like the biggest of issues for me so i didn't bother looking into it. Test dwg if you want to see the issue for yourself (use the red poly) Test.dwg Edited November 23, 2022 by Sambo Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.