nathanjh13 Posted January 24, 2011 Posted January 24, 2011 Thanks! But I can't as I don't seem to have any messaging privileges or anything. I think a moderator has asked you to post it to them and they'll upload it. That would be fantastic! Thank you very much Nathan Quote
asos2000 Posted January 24, 2011 Author Posted January 24, 2011 PM me with the lisp and I'll upload or email hasancad@gmail.com Quote
nathanjh13 Posted July 2, 2011 Posted July 2, 2011 Hi If somebody could resolve this, it would be really helpful A lisp for c.o.g of several separate solids is easy but I need one that treats all objects as if they were one (as if they were joined by UNION or GROUP) without me having to run UNION first etc thanks nathan Quote
krpruett Posted October 7, 2014 Posted October 7, 2014 Can anyone make changes to this so that you can calculate CG on multiple regions such as a plate with slots cut in it? See attached please CG Example.dwg Quote
marko_ribar Posted October 7, 2014 Posted October 7, 2014 (edited) Can anyone make changes to this so that you can calculate CG on multiple regions such as a plate with slots cut in it? See attached please Do you know that command "SUBTRACT" is applicable both to 3D SOLIDS and REGIONS? For centroid - CG, take look into this code : (defun c:centroid ( / v^v unit ucs x y ss ent enta n p ) (vl-load-com) (defun v^v ( u v ) (mapcar '(lambda ( s1 s2 a b ) (+ ((eval s1) (* (nth a u) (nth b v))) ((eval s2) (* (nth a v) (nth b u))))) '(+ - +) '(- + -) '(1 0 0) '(2 2 1)) ) (defun unit ( v ) (mapcar '(lambda ( x ) (/ x (distance '(0.0 0.0 0.0) v))) v) ) (if (/= (getvar 'worlducs) 1) (command "_.ucs" "_w") ) (setq ss (ssget "_+.:E:S" '((0 . "3DSOLID,REGION")))) (setq ent (ssname ss 0)) (setq enta (vlax-ename->vla-object ent)) (if (eq (cdr (assoc 0 (entget ent))) "REGION") (progn (setq n (vlax-safearray->list (vlax-variant-value (vla-get-normal enta)))) (if (equal (v^v n '(0.0 0.0 1.0)) '(0.0 0.0 0.0) 1e-6) (setq x '(1.0 0.0 0.0) y '(0.0 1.0 0.0)) (setq x (unit (v^v n '(0.0 0.0 1.0))) y (unit (v^v n x))) ) (command "_.explode" ent) (while (> (getvar 'cmdactive) 0) (command "") ) (setq p (vlax-curve-getstartpoint (entlast))) (command "_.undo") (while (> (getvar 'cmdactive) 0) (command "") ) (setq ucs (vla-add (vla-get-usercoordinatesystems (vla-get-activedocument (vlax-get-acad-object))) (vlax-3d-point p) (vlax-3d-point (mapcar '+ p x)) (vlax-3d-point (mapcar '+ p y)) "{ UCS }")) (vla-put-activeucs (vla-get-activedocument (vlax-get-acad-object)) ucs) (command "_.UCS" "_D" "{ UCS }") (vlax-release-object ucs) (setq cent (trans (vlax-safearray->list (vlax-variant-value (vla-get-centroid enta))) 1 0)) (command "_.ucs" "_p") ) (setq cent (vlax-safearray->list (vlax-variant-value (vla-get-centroid enta)))) ) (prompt "\nCentroid : ") (princ cent) (prompt "\nVariable is called \"cent\" - you call it with !cent") (princ) ) HTH, M.R. Edited July 29, 2015 by marko_ribar code changed Quote
krpruett Posted October 7, 2014 Posted October 7, 2014 The LISP doesn't help in my case. Did you see the example? The lisp above works but I can't select multiple objects and get one CG. Quote
marko_ribar Posted October 8, 2014 Posted October 8, 2014 The LISP doesn't help in my case. Did you see the example? The lisp above works but I can't select multiple objects and get one CG. You don't read what you see... You must use command "SUBTRACT" prior to using lisp routine... After running "SUBTRACT" command you should select firstly the biggest REGION and then cut-out REGIONS... You will get one subtracted REGION on which you should apply the code posted above... Quote
krpruett Posted October 8, 2014 Posted October 8, 2014 I want a LISP where I can create the region(s). Then run the LISP and select all of the regions, then it will draw a circle at the CG of all of them. Because the CG of a part is different if it has large slots or cutouts in it. I have a LISP that will do a singular object from user ASMI but I need one that will accommodate multiple regions without the use of other commands that waste time. I will be doing this on hundreds of parts so secondary and tertiary commands make the LISP pointless. Quote
DPS Posted February 15, 2017 Posted February 15, 2017 Hi all, I am new into your community and i am trying to use the lisps but i am missing something so it is not working into my drawings. The main scope is to give me the center of gravity directly from the polyline. I am creating the lisp file and insert into the autocad files but it is not working. 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.