Jump to content

Dimension styles - Place text automatically


Recommended Posts

Posted

Hey all,

 

Does anyone know of a lisp that goes through all the dimstyles and removes the option "place text manually". I want my measurment to automatically be centered on the dimension, and I frequently work with drawings that have many text styles that have the "place text manually" box checked off in the dimstyle properties.

 

Thanks!

Posted

I had the same problem not too long ago. Try this:

 


(defun c:fd( / ss eLst)
 (princ "\nSelect dimensions: ")
 (setq ss (ssget '((0 . "DIMENSION"))))
 (if ss
   (foreach forVar (vl-remove nil (mapcar '(lambda (x) (if (= (type (cadr x)) 'ENAME) (cadr x) '())) (ssnamex ss)))
     (setq eLst (entget forVar))
     (setq eLst (subst '(70 . 32) (assoc 70 eLst) eLst))
     (entmod eLst)
     (entupd forVar)
     )
   )
 ); Fix dimensions so text aligns in the center

Posted

This is good, but it looks like it takes each individual dimension. Do you know of a way to edit the dimension styles, so that future dimensions you create will automatically be centered?

Posted

hmm.. if you go to the modify dimensions window (command: "DIMSTYLE"), modify the one you want then click on the "TEXT" tab, under "Text alignment" (bottom right corner) you should see a radio button. Check to make sure that "Aligned with dimension line" is selected.

 

I'm afraid I haven't done much with dimension styles, so I think that's the best I can tell you.

Posted

I have some similar code provided by alanjt. I have highlighted what i think needs to be changed, but i am admittedly not very good at writing code yet.

 

(vl-load-com)

(defun C:dmanual ()

(vlax-for x (vla-get-TextStyles

(vla-get-activedocument (vlax-get-acad-object))

)

(princ)

(vla-setfont x "ARIAL" :vlax-False :vlax-False 0 32)

)

)

 

I think textstyles needs to be changed to dimstyles, and font x "ARIAL" :vlax-False :vlax-False 0 32 needs to be changed as well, but im not sure to what.

 

Any insight would be great!

Posted

Alan,

 

That is what i have been doing, but i have some drawings that have many dimstyles and it is time-consuming to go through the whole list.

 

I am looking to do it with a lisp, but i do not know the correct vla-set command (does anyone have a list of these commands handy?). Am i correct in assuming i should change "textstyles" to "dimstyles" ?

Posted
  RyanAtNelco said:
Alan,

 

That is what i have been doing, but i have some drawings that have many dimstyles and it is time-consuming to go through the whole list.

 

I am looking to do it with a lisp, but i do not know the correct vla-set command (does anyone have a list of these commands handy?). Am i correct in assuming i should change "textstyles" to "dimstyles" ?

 

 

This should get you started, can't edit current style (just how it is).

 

(defun test (#Name / #Style)
 (and (setq #Style (entget (tblobjname "dimstyle" #Name)))
      (entmod (append #Style (list (cons 288 0))))))

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