TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: hudster 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?
-
DXF group code 43 of the mtext entity.
43 Vertical height of the mtext entity
Do you know to extract the DXF code from the entity?
-
not yet :(
-
Yes you do. I know for a fact that Stig has taught you about cdr and assoc.
-
May be a bit confusing.
; 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))))
)
)
-
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/]
-
It's okay. Just take it as a hint.
-
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
Command: !DIST1
(43 . 10.8333)
Command: (CADR DIST1)
; error: bad argument type: consp 10.8333
so how can I extract the bit I need?
-
(cdr dist1)
not cadr. see above post of mine.
-
:oops:
-
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?
-
look into subst and >this< (http://www.theswamp.org/phpBB2/viewtopic.php?t=4590)
-
How are you doing with this? Need more?
-
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.
-
Here's how to do it using subst:
(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.
(setq new_insrt (list (car insrt) (- (cadr insrt) hgt) (caddr insrt)))
-
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: