Jump to content

Change textstyle to annotative


TAllen

Recommended Posts

Hey everyone,

 

My company wants to change the properties of a previously non-annotative text style to make it annotative. The style change will be set in the company template for all new projects, but that obviously won't affect any existing files. I'm trying to write some code to include in our acaddoc.lsp file so it will make this change to any document that is opened.

 

;;; change KARPL text style to annotative if it exists in a drawing

;; get style object if it exists
(setq styleobj (tblsearch "STYLE" "KARPL"))
(if (= styleobj nil)
(prompt "\nKARPL does not exist.")
)

;;if it does exist
(if (/= styleobj nil)

;;get style entity name
(setq stylename (tblobjname "STYLE" "KARPL"))

;;get xdata for entity
(setq annotx (cadr (assoc -3 (entget stylename '("AcadAnnotative")))))

;;get value of second 1070 dxf code
(setq bAnnotative (cdr (nth 4 annotx))) 

;;if either there is no xdata or the second 1070 code is 0, the style is not annotative
(if (OR (= annotx nil) (=bAnnotative 0))

	;;write correct xdata
	(setq exdata '((-3 ("AcadAnnotative" (1000 . "AnnotativeData") (1002 . "{") (1070 . 1) (1070 . 1) (1002 . "}")))))
	(setq styleobj (subst exdata (assoc -3 styleobj)))

	;;set text height to 1/16"
	(setq styleobj (subst (cons 40 0.0625) (assoc 40 styleobj) styleobj))

	;;modify styleobject
	(entmod styleobj)
)
(princ);_ end if
)

 

I'm having trouble figuring out how to write the corrected xdata and the new text height back to the style entity. Everything else seems to work.

Link to comment
Share on other sites

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