Jump to content

Recommended Posts

Posted

I have a drawing with multiple rotated dimensions and some are quite small resulting in text being offset to the leader. I was wondering if there is an easy way to change all the text box components of the dimensions to fit the actual size of the text so that it isn't so offset from the leader without exploding all the dimensions. I've included some snap shots below for reference. There are quite a few in the file so I want to try and avoid having to do them manually one by one.

 

Any help would be greatly appreciated.

 

Regards,

Ryan

 

image.png.2d4e031212d561439e5de3e0aeeb19d4.pngimage.png.6a653c145fe6395d922259a233c70cb9.pngimage.png.94c171e9978833a656f7b16a4f5675dd.pngimage.png.fb060a7de0d1ac6621b6aacea709293b.png   

 

 

Posted
11 minutes ago, BIGAL said:

Post a dwg need to see why its so far away.

I've attached a dwg with a couple of sample dimensions. It looks like the text box of the text is quite a lot larger than the actual text and then the text is centred? When I reduce the size of the text box to suit the text it isn't offset.

dim_test_file.dwg

Posted

How are you making the dimensions?

 

I made new dimensions in your drawing and they all had small text boxes.

Posted
18 hours ago, SLW210 said:

How are you making the dimensions?

 

I made new dimensions in your drawing and they all had small text boxes.

The issue is I'm trying to utilise dimensions in a file that has been given to me (the file I have has 100s of dimensions). I want to avoid having to manually recreate all the small dimensions which have the offset text. I'm not sure why they are created with text boxes so large in the first place. Anyway, I appreciate everyone's input.

Posted

I think you will need a LISP to modify an entire drawing at once.

Posted (edited)

Ok no idea why it worked but if you copy the dim, the copied object resets the text. Very limited testing. 

 

(defun c:dimfix ( / oldsnap ss ent entl ins ss)
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)
(setq ss (ssget '((0 . "dimension"))))
(repeat (setq x (sslength ss))
  (setq ent (ssname ss (setq x (1- x))))
  (command "copy" ent "" "0.0,0.0,0.0" "10.0,0.0,0.0")
  (setq entl (entlast))
  (command "erase" ent "")
  (command "move" entl "" "0.0,0.0,0.0" "-10.0,0.0,0.0")
)
(princ)
)
(c:dimfix)

 

 

OOPS had copy instead of move back to original.

 

Edited by BIGAL
Posted
21 hours ago, BIGAL said:

Ok no idea why it worked but if you copy the dim, the copied object resets the text. Very limited testing. 

 

(defun c:dimfix ( / oldsnap ss ent entl ins ss)
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)
(setq ss (ssget '((0 . "dimension"))))
(repeat (setq x (sslength ss))
  (setq ent (ssname ss (setq x (1- x))))
  (command "copy" ent "" "0.0,0.0,0.0" "10.0,0.0,0.0")
  (setq entl (entlast))
  (command "erase" ent "")
  (command "move" entl "" "0.0,0.0,0.0" "-10.0,0.0,0.0")
)
(princ)
)
(c:dimfix)

 

 

OOPS had copy instead of move back to original.

 

No such luck on my end. Appreciate the help Bigal

Posted

I tested with Bricscad V25 so just something in the way that does the copy. I looked around for ages for the hidden code/property if you tick on text box can see the padding around the text. 

Posted

Does anyone know of a way to set the mtext width to 0 for all the rotated dimensions in one go? Because that seems to be what I need.

 

image.png.49a23b2a4f165c915138fc80a6a44365.png

  • 10 months later...
Posted (edited)

I know its late by few months.  May be, somebody in future will find it useful.

I accidentally came across this post while browsing and found it interesting. So, I decided to have a go at it. After spending about 10 hours over 2 days (I am little out of touch with AutoCAD currently) exploring various options, I came out with following AutoLISP code that does the job.

 

It assumes that every dimension embeds exactly one and and only one Mtext object. 

 

(defun c:DimMTextWidSetZero ()
;;;;; Sets fixed width of MText (embedded in dimensions) in all dims to 0. No user interaction requred.
;;;;; Disclaimer: No error-checking or validation is included. 
  (vl-load-com)
  (setq reqdObjName "MTEXT")
  (setq dims (ssget "X" '((0 . "DIMENSION"))))
;;;; Create a selection set of all dims in the drawing.
  (setq kounter 0)
  (while (< kounter (sslength dims))
    (setq enameDim (ssname dims kounter))
;;;; Process the dims one by one
    (setq nameBlkDin (cdr (assoc 2 (entget enameDim))))
    (setq eNameBlkDim (tblobjname "Block" nameBlkDin))
    (setq reqdEnt (entnext eNameBlkDim))
    (setq objName (cdr (assoc 0 (entget reqdEnt))))
    (while (/= objName reqdObjName)
      (setq reqdEnt (entnext reqdEnt))
      (setq objName (cdr (assoc 0 (entget reqdEnt))))
    )
    (if	(= objName reqdObjName)
;;;;; If it is mtext
      (progn
	(setq objMtxt (vlax-ename->vla-object reqdEnt))
	(vlax-put-property objMtxt 'Width 0)
	(vla-Update objMtxt)
	(vla-Update (vlax-ename->vla-object enameDim))
      )
    )
    (setq kounter (1+ kounter))
  )
)

 

A couple of interesting points:

1. Nobody mentioned about DimStyle used - Dowels. If you insert a new dimension using the same dimstyle, there are no spaces. In fact there is no access manually to the 'Fixed Width' of MText embedded in a dimension.

2. I could not manually create a similar dimension, So it seems that the problem has been created by translation or the fixed width of the MText is modified using code AFTER dimensions have been inserted.
3. There is reliable / consistent method to manually modify the fixed width of the MText.

 

I have attached the drawing file generated after running the code. 

 

Enjoy!

dim_test_file_OUT.dwg

Edited by SanganakSakha

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