asdfgh Posted September 17, 2022 Posted September 17, 2022 Hello Everyone, is there any lisp can help me to put a point in the geometrec center of several closed polylines ? Thanks in Advance Quote
BIGAL Posted September 17, 2022 Posted September 17, 2022 Something like this (setq obj (vlax-ename->vla-object (entlast))) (setq cpt (osnap (vlax-curve-getStartPoint obj) "gcen")) Thanks to Kent Cooper for the hint about gcen 1 1 Quote
mhupp Posted September 17, 2022 Posted September 17, 2022 I think vlax-curve-getStartPoint works with entity names also. (setq cpt (osnap (vlax-curve-getStartPoint (entlast)) "gcen")) 1 Quote
asdfgh Posted September 20, 2022 Author Posted September 20, 2022 i found this lisp which is useful for everyone TMPOA.lsp Quote
tombu Posted September 20, 2022 Posted September 20, 2022 2 hours ago, asdfgh said: i found this lisp which is useful for everyone Better to provide a link to give credit to the author Kent Cooper which would be the source if anyone had any questions about the lisp. https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-subfunction-to-get-quot-center-quot-inside-closed-polyline/m-p/8747852#M384196 1 Quote
asdfgh Posted September 20, 2022 Author Posted September 20, 2022 7 minutes ago, tombu said: Better to provide a link to give credit to the author Kent Cooper which would be the source if anyone had any questions about the lisp. https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-subfunction-to-get-quot-center-quot-inside-closed-polyline/m-p/8747852#M384196 i didn't know who is the author as i got the lisp from a college not from internet but thanks for sharing the author with us he deserves the credit Quote
Tharwat Posted September 20, 2022 Posted September 20, 2022 Here you go. (defun c:Test (/ spc get sel int ent rgn) ;;----------------------------------------------------;; ;; Author : Tharwat Al Choufi ;; ;; website: https://autolispprograms.wordpress.com ;; ;;----------------------------------------------------;; (or *TH:doc* (setq *TH:doc* (vla-get-activedocument (vlax-get-acad-object))) ) (setq spc ((if (> (vla-get-activespace *TH:doc*) 0) vla-get-modelspace vla-get-paperspace) *TH:doc* ) ) (and (cond ((= 4 (logand 4 (cdr (assoc 70 (setq get (entget (tblobjname "LAYER" (getvar 'CLAYER)))) ) ) ) ) (alert "Current layer is locked. Unlock it and try again <!>") ) ((minusp (cdr (assoc 62 get))) (alert "Current layer is off. Turn it on and try again <!>") ) (t get) ) (setq int -1 sel (ssget "_:L" '((0 . "LWPOLYLINE") (-4 . "=") (70 . 1))) ) (or (zerop (getvar 'PDMODE)) (setvar 'PDMODE 3) ) (while (setq int (1+ int) ent (ssname sel int) ) (entmake (list '(0 . "POINT") (cons 10 (vlax-get (setq rgn (car (vlax-invoke spc 'addregion (list (vlax-ename->vla-object ent)) ) ) ) 'Centroid ) ) ) ) (and rgn (vla-delete rgn)) ) ) (princ) ) (vl-load-com) Quote
Steven P Posted September 20, 2022 Posted September 20, 2022 I wonder if this from Lee Mac is any good, http://www.lee-mac.com/ssboundingbox.html , gives the lower left and upper right corners of a selection set? Can get the cntre occrdinate from these Quote
BIGAL Posted September 21, 2022 Posted September 21, 2022 Steven P draw a pline as a "U" rotated and compare the methods suggested. You could average points also but it may not be geom centre. 1 Quote
abra-CAD-abra Posted September 21, 2022 Posted September 21, 2022 4 hours ago, Steven P said: I wonder if this from Lee Mac is any good, http://www.lee-mac.com/ssboundingbox.html , gives the lower left and upper right corners of a selection set? Can get the cntre occrdinate from these Maybe this little beauty? http://www.lee-mac.com/polygoncentroid.html Quote
Steven P Posted September 21, 2022 Posted September 21, 2022 It is tricky with the OP wanting the geometric centre of several objects. For a single object AutoCAD has an object snap of geometric centre (not sure about Bricscad, I assume it is similar), place a point there, no LISP required for just that. As above to get the centre if you need that point in a LISP.... for single polylines. Quote
tombu Posted September 21, 2022 Posted September 21, 2022 To check just GROUP them with GROUPDISPLAYMODE set at 1 or 2 (initial Value) the grip displayed would be the geometric center of the grouped objects. 1 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.