TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: ELOQUINTET on August 16, 2005, 11:26:12 AM
-
i had been working on a lisp with daron and i got a version using move command to work but am trying to now use entmod to move it instead and i can't seem to get it to move. i took the loacals out and tested it and everything appears to be working as far as i can tell but it's not moving the text. anyone know why? i'm going nuts over here. hellllllllllllp :cry:
(defun c:MTOentmod ()
(setq osm (getvar 'osmode))
(setvar "osmode" 0)
(setq txtentity (car (entsel "\nSelect text: "))
txtlist (entget txtentity)
pt1 (cdr (assoc 10 txtlist))
x1 (car pt1)
y1 (cadr pt1)
)
(setq dimentity (car (entsel "\nSelect dimension: "))
dimlist (entget dimentity)
pt2 (cdr (assoc 11 dimlist))
x2 (car pt2)
y2 (cadr pt2)
)
(if (< y1 y2)
(setq txtxcoord (car pt2)
txtycoord (cadr pt1)
pt3 (list txtxcoord txtycoord 0)
)
(setq txtxcoord (car pt1)
txtycoord (cadr pt2)
pt3 (list txtxcoord txtycoord 0)
)
)
(entmod (subst (cons 10 pt3)(cons 10 pt1) txtlist))
(setvar 'osmode osm)
(princ)
)
-
Dan, what is it supposed to be doing? I created a linear dimension and a piece of text, ran this code and the text moved to be on the dimension line.
-
it is supposed to be moving it under the dimension line below the text
-
OK, In that case, I'm confused as to why you are comparing the 2 y values. If you just want the text below the DimText you should get the DIMGAP variable then subtract that value from the Dim's y for the Text's new y. You should also set the Text's alignment type to TopCenter, which means setting the Text's group 11 value instead of the group 10.
Make sense?
-
So something like this, although you should probably take into account any text that is/should be rotated.
(defun c:MTO ()
(setq osm (getvar 'osmode))
(setvar "osmode" 0)
(setq txtentity (car (entsel "\nSelect text: "))
txtlist (entget txtentity)
txthgt (cdr (assoc 40 txtlist))
)
(setq dimentity (car (entsel "\nSelect dimension: "))
dimlist (entget dimentity)
pt2 (cdr (assoc 11 dimlist))
x2 (car pt2)
y2 (cadr pt2)
)
(setq pt3 (list (car pt2) (- (cadr pt2) (* 1.5 txthgt)) 0))
(setq newlist (subst (cons 11 pt3) (assoc 11 txtlist) txtlist)
newlist (subst (cons 72 1) (assoc 72 newlist) newlist)
newlist (subst (cons 73 3) (assoc 73 newlist) newlist)
)
(entmod newlist)
(setvar 'osmode osm)
(princ)
)
-
basically i am trying to make it work for both horizontal and vertical dimensions so that's what the comparison is all about. i was thinking the comparison should be equal not less than. this is the routine daron was helping me develop but he seems to have vanished (i don't blame him) i'm trying to figure out what dxf code i need to use for vertical dimensions and how to perform my test and branch the code. here's what i have now. i check it in vlide and it says it's ok but when i load it i get malformed list. why does the editor tell me it's ok but upon load it says malformed list. i'm getting really frustrated here :evil:
(defun c:MTOentmod (/)
(setq osm (getvar 'osmode))
(setvar "osmode" 0)
(setq txtentity (car (entsel "\nSelect text: "))
txtlist (entget txtentity)
pt1 (cdr (assoc 11 txtlist))
x1 (car pt1)
y1 (cadr pt1)
)
(setq dimentity (car (entsel "\nSelect dimension: "))
dimlist (entget dimentity)
pt2 (cdr (assoc 11 dimlist))
x2 (car pt2)
y2 (cadr pt2)
)
(if (not (= y1 y2))
(setq txtxcoord (car pt2)
txtycoord (cadr pt1)
pt3 (list txtxcoord txtycoord 0)
new (cons 21 pt2)
old (cons 21 pt1)
txtlist (subst new old txtlist)
)
(setq txtxcoord (car pt1)
txtycoord (cadr pt2)
pt3 (list txtxcoord txtycoord 0)
new (cons 11 pt3)
old (cons 11 pt1)
txtlist (subst new old txtlist)
)
)
(entmod txtlist)
(setvar 'osmode osm)
(princ)
)
-
jeff maybe this will give you a better idea of what i want to acheive. the one you put together is close but is not placing the text where i need it. in the illustration the vertical is correct and the horizontal is not. thank you for helping by the way
http://www.theswamp.org/screens/dan/lisp%20questions/mto.JPG
-
Before I respond any more I'm going to go read the other thread.......
-
jeff just so you know exactly what i'm working with here's an actual file. this was my first try at writing anything so it's just an exercise.
http://www.theswamp.org/lilly_pond/dan/test%20elevation.dwg?nossi=1
-
Well, dan, I'm still stuck in R2002 land, so I can't open that drawing.
Just a quick question....have you looked into using the "\X" for adding the text to the dimension text? Doing so would remove any need for determining the dimension's angle.
(defun c:MTO-jm (/ dim dimlst dimtxt txt txtlst txttxt)
(setq txt (car (entsel "\nSelect text: "))
dim (car (entsel "\nSelect dimension: "))
txtlst (entget txt)
dimlst (entget dim)
txttxt (cdr (assoc 1 txtlst))
dimtxt (cdr (assoc 1 dimlst))
)
(if (eq "" dimtxt)
(entmod (subst (cons 1 (strcat "<>\\X" txttxt)) (assoc 1 dimlst) dimlst))
(entmod (subst (cons 1 (strcat dimtxt "\\X" txttxt)) (assoc 1 dimlst) dimlst))
)
(entdel txt)
(princ)
)
-
wow a brilliant way of acheiving it (i'll have to file that in my memory) but i think this exercise is intended for me to understand dxf codes and how to extract the info i need. i will play with it some more :?
-
i think this exercise is intended for me to understand dxf codes and how to extract the info i need.
Could you have picked a more complicated example to do this with? :P
There are so many things with dimensions that you need to check in order to make a rock solid routine. Some of the DimVars that affect each Dimstyle, and potentially each dimension with overrides. These are stored in the dimension's Xdata:
DIMGAP
DIMJUST
DIMTAD
DIMTIH
DIMTOH
DIMTVP
And based on the values of those, you may, or may not, need to find the angle of the dimension line.
-
yeah i hear ya, bit off a little more than i can chew but hey might as well jump right in there :shock:
-
hmmm i'm still stuck, just can't seem to get it and i'm running out of patience. not sure what to do here sigh :?
-
jeff the question is begging to be asked about the last routine you posted. this works great if the text is in the default position but what if it is not. is there anyway to force \x to work when text is not in the default position???
-
Hmmm, I never thought about that. I just figured it would still work.....my comp. is currently tied up, but I'll look into this later on.
-
i also want to know this for another situation where it would be nice to be able to force the text beneath the dimension line. thanks
-
This is what I came up with when you & daron started the other thread.
Haven't revisited it but if the dimtxt is moved I think the added text will have to be
a separate text object if you want it below the dim line.
Removed
-
Oh yeah. Kill his patience entirely with ActiveX, CAB. :lol: Yes, that is meant as a joke.
As far as all the dimension variables, you also need to check for text justifications and that is its own headache. As far as why we started Dan out on something so difficult? He asked for it. I couldn't come up with a simpler idea, so I thought I'd see what we could do to run with it. To be perfectly honest, I think Dan has come a long way, just by having a desire to start learning this stuff. If someone can come up with something simpler that'll teach Dan to dig deeper and understand what the code syntaxes are doing and how they work or whatever, please do. I'm sure everyone can attest that they didn't have lisp down after their first program. I know I didn't. It took quite a few routine's.
-
Oh yeah. Kill his patience entirely with ActiveX, CAB. :lol: Yes, that is meant as a joke.
OK, let him wait on the vlisp. :)
I'll bring it back later.
-
You can repost it. Who knows when he'll be ready to get into AX? What Dan needs right now, is someone helping him get the basics with something basic. I'm not going to be getting in here much during the weekdays, so he'll need everyone's help.
-
thanks daron i figured you just got busy so i reposted so someone else could help me keep learning. and thanks to everyone who's helped so far preesh 8)