Author Topic: Mtext  (Read 4889 times)

0 Members and 1 Guest are viewing this topic.

hudster

  • Gator
  • Posts: 2848
Mtext
« on: April 19, 2005, 08:02:54 AM »
I'm attempting to write a lisp to move notes to a set distance under the last note.

As these notes are in mtext, is there a way I can extract the height of a peiece of mtext, not the text height.

i.e if there is 2 lines it's the text height + 1.66 (for the text gap).

any ideas?
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Mtext
« Reply #1 on: April 19, 2005, 08:32:35 AM »
DXF group code 43 of the mtext entity.

Quote
43  Vertical height of the mtext entity


Do you know to extract the DXF code from the entity?
TheSwamp.org  (serving the CAD community since 2003)

hudster

  • Gator
  • Posts: 2848
Mtext
« Reply #2 on: April 19, 2005, 08:57:56 AM »
not yet :(
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

daron

  • Guest
Mtext
« Reply #3 on: April 19, 2005, 09:02:41 AM »
Yes you do. I know for a fact that Stig has taught you about cdr and assoc.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Mtext
« Reply #4 on: April 19, 2005, 09:09:35 AM »
May be a bit confusing.
Code: [Select]

; if user selects something
 (if (setq ent (car (entsel "\nSelect MTEXT: ")))
   ; if the selected entity is MTEXT
   (if (= (cdr (assoc 0 (entget ent))) "MTEXT")
     ; set variable 'mt_height' (real)
     (setq mt_height (cdr (assoc 43 (entget ent))))
     )
   )
TheSwamp.org  (serving the CAD community since 2003)

hudster

  • Gator
  • Posts: 2848
Mtext
« Reply #5 on: April 19, 2005, 09:14:42 AM »
Quote from: Daron
Yes you do. I know for a fact that Stig has taught you about cdr and assoc.


I'm behind in my class work :(

[/hangs head in shame/]
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

daron

  • Guest
Mtext
« Reply #6 on: April 19, 2005, 09:29:10 AM »
It's okay. Just take it as a hint.

hudster

  • Gator
  • Posts: 2848
Mtext
« Reply #7 on: April 19, 2005, 12:01:32 PM »
Right i've manged to extract the part I want using assoc.

so i now have (43 . 10.8333), but I can't extract the 10.8333 part I want.

I get this

Code: [Select]
Command: !DIST1
(43 . 10.8333)

Command: (CADR DIST1)
; error: bad argument type: consp 10.8333


so how can I extract the bit I need?
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Mtext
« Reply #8 on: April 19, 2005, 12:04:19 PM »
Code: [Select]
(cdr dist1) not cadr. see above post of mine.
TheSwamp.org  (serving the CAD community since 2003)

hudster

  • Gator
  • Posts: 2848
Mtext
« Reply #9 on: April 19, 2005, 12:05:02 PM »
:oops:
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

hudster

  • Gator
  • Posts: 2848
Mtext
« Reply #10 on: April 19, 2005, 02:13:20 PM »
Right I've almost got it now.

I've extracted the co-ordinates of the mtext insertion point using (setq insrt (assoc 10 ss1) and get this as a result, (10 66.667 641.144).

To change the Y co-ordinate do I have to break down the list to indivdual strings to change the Y co-ordinate or can I change it another way?
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

daron

  • Guest
Mtext
« Reply #11 on: April 19, 2005, 04:05:54 PM »
look into subst and >this<

daron

  • Guest
Mtext
« Reply #12 on: April 20, 2005, 08:35:45 AM »
How are you doing with this? Need more?

hudster

  • Gator
  • Posts: 2848
Mtext
« Reply #13 on: April 20, 2005, 03:59:50 PM »
I was looking at subst, but it doesn't really do what I want it to.

What I want is to take the co-ordinates of the Mtext insertion, subtract the mtext height from the Y co-ordinate and use this value as a point to copy to.

What I did, was use the list command to build a new point list to use as a co-ordinate, but I think there must be another, better way to do this.
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Mtext
« Reply #14 on: April 20, 2005, 04:13:58 PM »
Here's how to do it using subst:
Code: [Select]
(setq ss1 (entget (car (entsel "\nSelect mtext: "))))
(setq insrt (cdr (assoc 10 ss1)))
(setq hgt (cdr (assoc 43 ss1)))
(setq new_insrt (subst (- (cadr insrt) hgt)(cadr insrt) insrt))

But, I would suggest recreating the list since this will fail if the X & Y values are identical.
Code: [Select]
(setq new_insrt (list (car insrt) (- (cadr insrt) hgt) (caddr insrt)))

hudster

  • Gator
  • Posts: 2848
Mtext
« Reply #15 on: April 20, 2005, 05:21:04 PM »
cool.

I did everything the same up to the last line, then i went off into a ramble, breaking down the points to individual values before altering them and reconstructing the list.

I still have a lot to learn. :shock:
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue