Jump to content

Recommended Posts

Posted

I am wondering if there is a snap setting I am unable to find that would show the "apparent center" (basicaly, the center of the mass if it was solid) of a square, rectangle, or any other odd shaped polyline. I see it in circles but not other shapes.

  • Replies 32
  • Created
  • Last Reply

Top Posters In This Topic

  • David D

    13

  • BlackBox

    10

  • SLW210

    4

  • alanjt

    3

Popular Days

Top Posters In This Topic

Posted Images

Posted

Try Mid Between Two Points (_m2p) for your osnap.

 

For example:

 

To snap to the center of a rectangle, start the line command and Shift + Right Click, pick 'Mid Between 2 Points', then select the lower left, and upper right corners of the rectangle.

Posted

From draftsperson.net:

 

With the creation of a REGION or a 3D SOLID, it is possible to find the centroid of an object, with the MASSPROP function. MASSPROP is an AutoCAD function.

Posted
From draftsperson.net:

 

With the creation of a REGION or a 3D SOLID, it is possible to find the centroid of an object, with the MASSPROP function. MASSPROP is an AutoCAD function.

 

@ Mark -

 

That won't work for a Polyline entity... the OP used Solid as an example, as you can snap to the centroid of the Region/Solid, but the OP wants to avoid that step altogether (as I understand it). More information is needed.

 

@ Davd -

 

I am wondering if there is a snap setting I am unable to find that would show the "apparent center" ... of a square, rectangle, or any other odd shaped polyline. I see it in circles but not other shapes.

 

How are you intending to 'show' the centroid?

 

Do you mean using a line command, etc. you want to snap to the centroid of a given polyline, or do you want to pick a polyline, and mark the centroid by placing a point object, etc.?

Posted

Renderman, I do not see the mp2 option. What I want it for is to position text that is middle center justified for aesthetic purposes. Shapes I am using are tool outlines, all sorts, sizes and shapes. I am working in 2d.

Thank you

Posted

The m2p or mtp option is a command modifier. You have to use AFTER starting the command you are working with like Move, or Line or Circle, etc.

Posted
Renderman, I do not see the mp2 option. What I want it for is to position text that is middle center justified for aesthetic purposes. Shapes I am using are tool outlines, all sorts, sizes and shapes. I am working in 2d.

Thank you

 

The m2p or mtp option is a command modifier. You have to use AFTER starting the command you are working with like Move, or Line or Circle, etc.

 

Correct. You must manually (or programmatically) enter "_m2p" once you've bagan a command.

 

Using your example, of moving text:

 

Select the text, select the insertion grip (you listed Middle Center), then begin to move your mouse (you should see the text moving along), now at the keyboard type in "_m2p" (without the quotes) and hit Enter. You should now be prompted to select two points sequencially.

 

Give it a try. :wink:

Posted

Tried it. After typing _m2p and hit Enter I get this "Point or option keyword required."

Posted
Tried it. After typing _m2p and hit Enter I get this "Point or option keyword required."

 

Works on my end (and has for years):

 

Command:

** STRETCH **
Specify stretch point or [base point/Copy/Undo/eXit]:
>>Enter new value for ORTHOMODE <1>:
Resuming GRIP_STRETCH command.

Specify stretch point or [base point/Copy/Undo/eXit]: [color=red]_M2P
[/color][color=red]First point of mid: Second point of mid:
[/color]Command: *Cancel*

Posted

I worked with the sequence and got to work. Since I am doing this for many, many, many drawings I need to make a button with a macro (i think, new to this so may not have correct terminoligy) should I pursue this in this thread or start a new one.

Posted

I remember in Bricscad there is a snap point in the center of rectangles, triangles and other closed regular polylines. It is like the center of the circles.

Posted
I worked with the sequence and got to work. Since I am doing this for many, many, many drawings I need to make a button with a macro (i think, new to this so may not have correct terminoligy) should I pursue this in this thread or start a new one.

 

It would be easier to follow if you just stayed in this thread, I can relocate and retitle the thread if you like.

Posted

Thank you SLW that would be great.

Posted (edited)
I worked with the sequence and got to work. Since I am doing this for many, many, many drawings I need to make a button with a macro (i think, new to this so may not have correct terminoligy) should I pursue this in this thread or start a new one.

 

Welcome to CADTutor, newbie! :)

 

Here's a LISP freebie:

 

(defun c:TPC () (c:Text2PlineCentroid))
(defun c:Text2PlineCentroid (/ *error* ssText flag eName oText ssPline oPline centroid oName)
 (princ "TEXT 2 POLYLINE CENTROID ")
 (vl-load-com)

 (defun *error*  (msg)
   (and flag (not (redraw eName 4)))
   (cond ((not msg))                                                   ; Normal exit
         ((member msg '("Function cancelled" "quit / exit abort")))    ; <esc> or (quit)
         ((princ (strcat "\n** Error: " msg " ** "))))                 ; Fatal error, display it
   (princ))
 
 (if (and (setq ssText (ssget ":S:E" '((0 . "MTEXT,TEXT"))))
          (and (setq flag T)
               (not (redraw (setq eName (ssname ssText 0)) 3)))
          (setq oText (vlax-ename->vla-object eName))
          (setq ssPline (ssget ":S:E" '((0 . "*POLYLINE"))))
          (setq oPline (vlax-ename->vla-object (ssname ssPline 0))))
   (progn
     (vla-getboundingbox oPline 'mn 'mx)
     (setq centroid
            (vlax-3d-point
              (mapcar '*
                      (mapcar '+
                              (vlax-safearray->list mn)
                              (vlax-safearray->list mx))
                      '(0.5 0.5 0.5))))
     (vla-move
       oText
       (cond
         ((= "AcDbMText" (setq oName (vla-get-objectname oText)))
          (vla-get-insertionpoint oText))
         ((= "AcDbText" oName)
          (vla-get-textalignmentpoint oText)))
       centroid))
   (cond
     (ssText (prompt "\n** Nothing selected ** "))
     ((prompt "\n** Nothing selected, or text layer is locked ** "))))
 (princ))

 

Cheers! :beer:

Edited by BlackBox
Added condition for InsertionPoint / TextAlignmentPoint
Posted

Go search theswamp for Gile's additional osnaps program. The centroid snap is beyond useful.

 

ctr.gif

Posted

Thanks Renderman but although it looks like Excel VBA which I am familiar with I have so far only heard of Lisp and do not even know whre or how to to put this code. That is why I was thinking a button, or does this go in the line where you would write a button macro?

Posted
Go search theswamp for Gile's additional osnaps program. The centroid snap is beyond useful.

 

Awesome!

 

Peter%2BGriffin.jpg

 

Ehhhhehehehehehehee

Posted
Thanks Renderman but although it looks like Excel VBA which I am familiar with I have so far only heard of Lisp and do not even know whre or how to to put this code. That is why I was thinking a button, or does this go in the line where you would write a button macro?

 

*cough*I'd check out Alan's suggestion*cough*

 

To execute the code I posted from a toolbar button macro:

 

Save the code I posted to a file ("Text2Centroid.LSP"?) to a location which resides within your Support File Search Paths.

 

Sample macro (from memory):

 

^C^C(if (not c:TPC) (load "Text2Centroid.lsp"));TPC;

Posted

alanjt, thank you. I was able to load the lisp.

Renderman, I was able to create the button I wanted so I do not really need the lisp. I tried the lisp but I think I will need step by step instructions on how to make it work. I can select the text and see the snap points for the polyline but when I click on the first one to choose it the text goes there right away without the opportunity to choose the second point. If I want to know more about lisp's and how they work it would be helpfull to know why it is not working. Your choice to continue or not.

 

Thank you very much to all who helped. Great forum!

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