kaan27 发表于 2022-7-6 06:09:42

center of pressure (center of

(defun eea-centroid-curve-lw (pl bl / L)                            ;|*****************************************************************************************by ElpanovEvgeniy*****************************************************************************************Library function.The center of the weight located along a contour of a lwpolyline, having arc segments.As an example, the center of weight of a wire detail!!! For the closed polylines to add the description of a closing segment.pl - list pointbl - list bulgeDate of creation   2000 - 2005 years.Last edit 08.06.2009*****************************************************************************************(setq e(car (entsel "\n Select LWPOLYLINE "))   pl nil   bl nil) ;_setq(foreach a (reverse (entget e))(cond ((= (car a) 10) (setq pl (cons (cdr a) pl)))      ((= (car a) 42) (setq bl (cons (cdr a) bl)))) ;_cond) ;_foreach(eea-centroid-curve-lw pl bl)*****************************************************************************************(defun c:c2 (/ e bl pl)(setq e (car (entsel)))(foreach a (reverse (entget e)) (cond ((= (car a) 10) (setq pl (cons (cdr a) pl)))       ((= (car a) 42) (setq bl (cons (cdr a) bl))) ) ;_cond) ;_foreach(if (= (cdr (assoc 70 (entget e))) 1) (setq pl (reverse (cons (car pl) (reverse pl))))) ;_if(entmakex (list '(0 . "point")                '(62 . 2)                (cons 10 (eea-centroid-curve-lw pl bl))                (assoc 210 (entget e))          ) ;_list) ;_entmakex) ;_defun*****************************************************************************************|;(setq l 0)(mapcar (Function /) (apply(function mapcar)(cons   (function +)   (mapcar    (function   (lambda (p1 p2 b / BB C D S)      (if (zerop b)       (progn (setq d (distance p1 p2)                  l (+ d l)            ) ;_setq            (mapcar (function (lambda (a b c) (* (/ (+ a b) 2) c))) p1 p2 (list d d))       ) ;_progn       (progn (setq c(distance p1 p2)                  bb (* b b)                  d(/ (* c (atan b) (1+ bb)) b)                  l(+ d l)                  s(- (/ 1 (* 4 (atan b))) (/ (- 1 bb) (* 4 b)))            ) ;_setq            (mapcar (function (lambda (a b c) (* d (+ (/ (+ a b) 2) c))))                      p1                      p2                      (list (* s (- (cadr p2) (cadr p1))) (* s (- (car p1) (car p2))))            ) ;_mapcar       ) ;_progn      ) ;_if   ) ;_lambda    ) ;_function    pl    (cdr pl)    bl   ) ;_mapcar) ;_cons ) ;_apply (list l l)) ;_mapcar) ;_defun
 
Hi, this lisp calculate center of weight for the closed polylines but I have a problem if it is applied a piercing operation on the material how do I calculate the center of weight. I need a lisp (only geometry not region).
 

 

 

 
Many thanks in advance for your help.

Tiger 发表于 2022-7-6 06:13:49

Hi Kaan and welcome to the forums. I added code-tags around your lisp to make it more readable.

Organic 发表于 2022-7-6 06:17:25

See http://forums.augi.com/showthread.php?5641-Getting-the-centroid-of-closed-polyline for info on finding the centroid.

kaan27 发表于 2022-7-6 06:19:55

I do not want to calculate centroid I want to calculate center of pressure. That is, they are different things. Center of pressure the center of gravity of the perimeter of blank (not the area blank). The above lisp calculates it but How do I calculate that when there is a hole on the figure.

neophoible 发表于 2022-7-6 06:23:57

For a 2D object, centroid is the correct term for whatever shape you have.Have you looked at using REGION, SUBTRACT & MASSPROP?There is probably a LISP routine floating around that would plot the resultant X-Y point of the centroid, but you can do it manually using cut & paste.

LINHOREKA 发表于 2022-7-6 06:28:39

You can specify center of each polyline, let denote them C1 and C2. The mass of each polyline is proportional to the length, let say L1 and L2. Then the center of the 2 would lay in the middle of C1 and C2, where L1 and L2 get balance.

kaan27 发表于 2022-7-6 06:29:40


 
there is an example for manual calculation. When there is a hole on the figure I need to subtract the length of the perimeter of the hole. Then center of gravity will change. I wonder how a lisp can be written.

neophoible 发表于 2022-7-6 06:32:43

Is there some reason you don't want to try this?Why not try it on your example?

kaan27 发表于 2022-7-6 06:35:35

I tried that but it didn't work.First I used region command then shape has become single with subtract command but above lisp can't calculate it.

neophoible 发表于 2022-7-6 06:38:50

Did you try MASSPROP?
页: [1] 2
查看完整版本: center of pressure (center of