Jump to content

Recommended Posts

Posted

cad version 2009 ,can anybody help

Posted
cad version 2009 ,can anybody help

 

Is it closed ?

Can you post image or a dwg of that shape ?

 

Tharwat

Posted

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.

Posted

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.

Posted
yes it is closed

 

Check the property of the object and it is not closed .

 

Select shape and press Ctrl+1

Posted

Thanks everybody . It works.

Posted

Good call Mircea, it seems that lots of users overlook the MASSPROPERTIES functionality. :thumbsup:

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 :beer:

Posted
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.

Posted
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. :beer:

All's well that ends well.

unclosed polyline.jpg

Posted

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)
)

Posted

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...... :oops:

Didn't do a very good job of that, sorry! :)

Posted
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...... :oops:

Didn't do a very good job of that, sorry! :beer:

 

It's Ok :thumbsup:

 

Cheers

Posted

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

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...