Author Topic: How to change text styles associated with linetypes?  (Read 2648 times)

0 Members and 1 Guest are viewing this topic.

T.Willey

  • Needs a day job
  • Posts: 5251
How to change text styles associated with linetypes?
« on: August 01, 2007, 05:35:43 PM »
I can't seem to figure it out.  I have this one drawing where there is a style with no name, and it is only associated with a linetype.  I have code that I think should work, but it doesn't work to change the text style.  Nor do I see anything in the help that says you can't change the text style of a linetype.  I'm attaching a drawing that shows the problem.

Thanks in advance.

Code: [Select]
(defun c:ChangeLinetypeFont (/ data cnt templist newdata styent)

(setq data (entget (tblobjname "ltype" "zigzag")))
(setq cnt 0)
(setq styent (tblobjname "style" "Standard"))
(while (< cnt (length data))
 (setq templist (nth cnt data))
 (if (equal (car templist) 340)
  (progn
   (prompt (strcat "\n Old font name: " (cdr (assoc 2 (entget (cdr templist))))))
   (setq newdata (append newdata (list (cons 340 styent))))
   (print (entmod newdata))
  )
  (if (not newdata)
   (setq newdata (list templist))
   (setq newdata (append newdata (list templist)))
  )
 )
 (setq cnt (1+ cnt))
)
(princ)
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: How to change text styles associated with linetypes?
« Reply #1 on: August 01, 2007, 06:00:35 PM »
Hint, it's not a Text style. It's a Shape for use in a Linetype whose definition is in the ltypeshp.shx, which one to use is determined by the Assoc 75 code, 131 in this case. This is the code you'd need to change if you want to change it.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: How to change text styles associated with linetypes?
« Reply #2 on: August 01, 2007, 06:13:17 PM »
This isn't sinking in as quickly as I would have hoped.  :-)

So since code 74 is 4, then there is an embedded shape.  So code 75 tells us what shape it is, 131.  Then code 340 tells us the shape file, even though if you look at it, it says its an "AcDbTextStyleTableRecord"?

If so.... Then if code 74 was a 2, then code 75 would be the text string value, and code 340 would correspond to a text style?

Man, that seems wrong, but also right at the same time.  I guess I need to do some testing, but please let me know if I'm on the right track.

Thanks.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: How to change text styles associated with linetypes?
« Reply #3 on: August 01, 2007, 06:25:44 PM »
Yep, that's pretty much it!

T.Willey

  • Needs a day job
  • Posts: 5251
Re: How to change text styles associated with linetypes?
« Reply #4 on: August 01, 2007, 06:29:21 PM »
Okay, so my last post was pretty much right, except that code 9 will hold the text string if code 74 is 2.

Even with that I can't seem to mod a linetype entity.  I tried to change the style of one that uses text styles, and I tried to change one's text value, and neither one worked.  Am I doing something wrong?  Here is the code I used.
Code: [Select]
(setq tempdata (entget (tblobjname "ltype" "HOT_WATER_SUPPLY")))
(setq temp (tblobjname "style" "p100"))
(entmod (subst (cons 340 temp) (assoc 340 tempdata) tempdata))
Returned 'nil'.
Code: [Select]
(entmod (subst (cons 9 "Stupid") (assoc 9 tempdata) tempdata))
Returned 'nil'.
Code: [Select]
(entmod (subst (cons 9 "Ya") (assoc 9 tempdata) tempdata))
Returned 'nil'.

Maybe I'm just not meant to change the text value of a linetype by code.  :oops:

Thanks Jeff.  :-)
« Last Edit: August 01, 2007, 06:30:22 PM by T.Willey »
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: How to change text styles associated with linetypes?
« Reply #5 on: August 01, 2007, 07:04:39 PM »
Well Tim, this is dragging stuff out of the cobwebs, but I seem to recall finding out that you cannot entmake or entmod linetypes. They must be loaded from a .lin file.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: How to change text styles associated with linetypes?
« Reply #6 on: August 01, 2007, 07:23:50 PM »
Well Tim, this is dragging stuff out of the cobwebs, but I seem to recall finding out that you cannot entmake or entmod linetypes. They must be loaded from a .lin file.
Okay.  I don't think I will need to edit them anyway, but I just noticed them when updating my merge text routine.  I thought one more item to merge.  Maybe I will look a little more in the help files, as I didn't anything that said I couldn't.

Thanks again Jeff.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.