Jump to content

LISP for Center Of Gravity


DPS

Recommended Posts

Hi i am new into the community and i am trying to find the way. I am actually trying to use some old lisp to generate the center of gravity directly on the selected polylines and point it out with a circle point.

Link to comment
Share on other sites

I have several sections from where i want to find the center of gravity for the different type of material. Afterwards i will create a polyline at the plan view in order for me to calculate the actual length for every material. Check the attached dwg.sample2.pdf i can't upload the CAD format

sample1.pdf

Link to comment
Share on other sites

That is the lisp i found, but how is that working?? i upload it into autocad and it doesn't give something.

(defun LM:PolyCentroid ( e / l )

(foreach x (setq e (entget e))

(if (= 10 (car x)) (setq l (cons (cdr x) l)))

)

(

(lambda ( a )

(trans

(mapcar '/

(apply 'mapcar

(cons '+

(mapcar

(function

(lambda ( a b )

(

(lambda ( m )

(mapcar

(function

(lambda ( c d ) (* (+ c d) m))

)

a b

)

)

(- (* (car a) (cadr b)) (* (car b) (cadr a)))

)

)

)

l (cons (last l) l)

)

)

)

(list a a)

)

(cdr (assoc 210 e)) 0

)

)

(* 3.0

(apply '+

(mapcar

(function

(lambda ( a b )

(- (* (car a) (cadr b)) (* (car b) (cadr a)))

)

)

l (cons (last l) l)

)

)

)

)

)

Link to comment
Share on other sites

There was more than one lisp routine in the thread. That's why I said to read the entire thread first. If one routine doesn't work then you try a different one.

 

Maybe it didn't work because the object(s) you selected were invalid.

 

There are many center of gravity lisp routines available but most probably only work where an area or a volume is involved which is not the case in your situation.

 

I have no use for COG lisp routines in my line of work so I cannot tell you which lisp routine will best suit your needs. It's trial and error time for you.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...