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

when I load the lisp it gives error. (Select LWPOLYLINE ; error: too few arguments)

neophoible 发表于 2022-7-6 06:47:19

You can try this snippet of code as well.Just select your REGION you made.

(vlax-get (vlax-ename->vla-object (car (entsel))) 'Centroid)Taken from this link: http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/massprop-where-the-values-are-stored/td-p/2288271
 
But you avoided my question about MASSPROP.

kaan27 发表于 2022-7-6 06:48:21

massprop command calculates according to area but I want to calculate according to perimeter. They are different calculations.
 

LINHOREKA 发表于 2022-7-6 06:52:55

If you do not want the center of the area (centroid), but only the center gravity of the lines, why there is any hole (while there is no area) ?
Anyway, you can combine your lisp with hand calculation. Programming is for doing something very frequently, hence, save alot of time. Your job doesnot look quite common.

Organic 发表于 2022-7-6 06:56:01

I've never heard of centre of gravity calculations based just upon shape perimeters. Calculating the centroid will achieve the same result.
 
My centroid calculations are rusty, although you will need to break the shape up into elements. E.g. if you had a T beam you could break it into two elements (the horizontal flange and the vertical web). Given you have a circle hole, this is not easy to do by hand.

kaan27 发表于 2022-7-6 07:00:16

The surface of the part is not empty, so there is a hole (piercing operation). When calculating the area instead of getting perimeter one by one. Calculating by hand easily but lisp unable.

Organic 发表于 2022-7-6 07:01:45

 
If the part has a surface, then it has an area. You can then find the (2d) centroid of the area/part which is your centre of gravity/mass. Otherwise I am not understanding your question. If your part is 3D, then it will be more complex.
 
You might need to post an example hand calculation (all steps etc) so someone can advise you where to start to program it.

kaan27 发表于 2022-7-6 07:05:19

Center of pressure is calculated in this way in press tooling operation
 

kaan27 发表于 2022-7-6 07:06:49

kaan27 发表于 2022-7-6 07:11:21

This would be more understandable, I guess.
页: 1 [2]
查看完整版本: center of pressure (center of