Tharwat Posted July 25, 2012 Posted July 25, 2012 cad version 2009 ,can anybody help Is it closed ? Can you post image or a dwg of that shape ? Tharwat Quote
MSasu Posted July 25, 2012 Posted July 25, 2012 Use REGION command to transform the said shape into a region entity and after apply the MASSPROP command on it – along other features will return the center of gravity too. The region entity support also boolean operation – that it, if case, you can create holes in that shape (SUBTRACT) or define it from two or more parts that are not in touch (UNION). As Tharwat observed, the center of gravity have no meaning for a contour with gaps. Quote
MSasu Posted July 25, 2012 Posted July 25, 2012 Just use the solution I suggested above - it will give you the desired information (listed as X and Y coordinates in current UCS under Centroid criteria). Out of curiosity, what units do you use? The size of that shape is huge (167794 x 105499) in drawing units. Quote
Tharwat Posted July 25, 2012 Posted July 25, 2012 yes it is closed Check the property of the object and it is not closed . Select shape and press Ctrl+1 Quote
Dadgad Posted July 25, 2012 Posted July 25, 2012 Good call Mircea, it seems that lots of users overlook the MASSPROPERTIES functionality. The units are inches. Based on the ASSUMPTION that it is drawn full size in modelspace, as it should be. I drew a line of 1500 units and put an architectural dimension on it and it gave me 125'. 1500/125=12 Quote
MSasu Posted July 25, 2012 Posted July 25, 2012 Check the property of the object and it is not closed This in not mandatory; as long the ends of that contour are in contact, the entity will be accepted by REGION command. Quote
Dadgad Posted July 25, 2012 Posted July 25, 2012 yes it is closed Tharwat is absolutely 100% correct. It appears to be closed, but is not, and yet Mircea's region technique is unaffected by that. All's well that ends well. Quote
Tharwat Posted July 25, 2012 Posted July 25, 2012 Here is my code but on closed Polylines only . (defun c:Test (/ spc s) ;;; Tharwat 25. July. 2012 ;;; (vl-load-com) (if (not acdoc) (setq acdoc (vla-get-activedocument (vlax-get-acad-object))) ) (setq spc (if (> (vla-get-activespace acdoc) 0) (vla-get-modelspace acdoc) (vla-get-paperspace acdoc) ) ) (while (setq s (ssget "_+.:S" '((0 . "LWPOLYLINE") (-4 . "&=") (70 . 1)))) (progn (setq cn (vlax-get (setq r (car (vlax-invoke spc 'addregion (list (vlax-ename->vla-object (ssname s 0))) ) ) ) 'centroid ) ) (print cn) (vla-delete r) ) ) (princ) ) Quote
Dadgad Posted July 25, 2012 Posted July 25, 2012 Tharwat, I am very sorry, I am typing on my dell and I get lots of double entries. When I first posted that I noticed that there was an extra 't' at the end of your name, went right back in to fix it...... Didn't do a very good job of that, sorry! Quote
Tharwat Posted July 25, 2012 Posted July 25, 2012 Tharwat, I am very sorry, I am typing on my dell and I get lots of double entries.When I first posted that I noticed that there was an extra 't' at the end of your name, went right back in to fix it...... Didn't do a very good job of that, sorry! It's Ok Cheers Quote
amarcon Posted July 25, 2012 Posted July 25, 2012 Here is a solution I stumbled across a while ago. This was *free* so I hope the author doesn't mind me sharing (could not find the old link). To test, simply drag/drop attached 'Centroid.vlx' (within attached ZIP archive) on your drawing and type CENTROID. Select Polyline, Region or 3D Solid. I use it to check my other routines when I have complex 3D solids, however, just as useful in the 2D world as well. Hint just adjust PDMODE = 66 to see centroid clearer. Centroid.zip 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.