DPS Posted February 16, 2017 Share Posted February 16, 2017 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. Quote Link to comment Share on other sites More sharing options...
ReMark Posted February 16, 2017 Share Posted February 16, 2017 (edited) You might find a solution in this thread. Read through the whole thread first. http://www.cadtutor.net/forum/showthread.php?65046-center-of-gravity-of-open-polyline Edited February 16, 2017 by ReMark Quote Link to comment Share on other sites More sharing options...
DPS Posted February 16, 2017 Author Share Posted February 16, 2017 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 Quote Link to comment Share on other sites More sharing options...
ReMark Posted February 16, 2017 Share Posted February 16, 2017 Did you look at the thread I provided the link to? Quote Link to comment Share on other sites More sharing options...
DPS Posted February 16, 2017 Author Share Posted February 16, 2017 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) ) ) ) ) ) Quote Link to comment Share on other sites More sharing options...
ReMark Posted February 16, 2017 Share Posted February 16, 2017 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. Quote Link to comment Share on other sites More sharing options...
DPS Posted February 16, 2017 Author Share Posted February 16, 2017 It finally works!! Thanks a lot!! Quote Link to comment Share on other sites More sharing options...
ReMark Posted February 16, 2017 Share Posted February 16, 2017 It finally works!! Thanks a lot!! I'm glad to hear that you have found a solution that works. Thank you for updating us. Quote Link to comment Share on other sites More sharing options...
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.