Author Topic: why isn't this working!!!!!!  (Read 6199 times)

0 Members and 1 Guest are viewing this topic.

ELOQUINTET

  • Guest
why isn't this working!!!!!!
« 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:

Code: [Select]
(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)
)

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
why isn't this working!!!!!!
« Reply #1 on: August 16, 2005, 02:07:32 PM »
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.

ELOQUINTET

  • Guest
why isn't this working!!!!!!
« Reply #2 on: August 16, 2005, 02:42:49 PM »
it is supposed to be moving it under the dimension line below the text

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
why isn't this working!!!!!!
« Reply #3 on: August 16, 2005, 03:25:43 PM »
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?

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
why isn't this working!!!!!!
« Reply #4 on: August 16, 2005, 03:41:52 PM »
So something like this, although you should probably take into account any text that is/should be rotated.
Code: [Select]

(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)
)

ELOQUINTET

  • Guest
why isn't this working!!!!!!
« Reply #5 on: August 16, 2005, 03:56:38 PM »
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:





Code: [Select]
(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)
  )
 

ELOQUINTET

  • Guest
why isn't this working!!!!!!
« Reply #6 on: August 16, 2005, 04:07:48 PM »
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

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
why isn't this working!!!!!!
« Reply #7 on: August 16, 2005, 04:17:04 PM »
Before I respond any more I'm going to go read the other thread.......

ELOQUINTET

  • Guest
why isn't this working!!!!!!
« Reply #8 on: August 16, 2005, 04:26:11 PM »
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

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
why isn't this working!!!!!!
« Reply #9 on: August 16, 2005, 04:59:18 PM »
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.
Code: [Select]

(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)
  )

ELOQUINTET

  • Guest
why isn't this working!!!!!!
« Reply #10 on: August 16, 2005, 06:09:12 PM »
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  :?

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
why isn't this working!!!!!!
« Reply #11 on: August 16, 2005, 08:39:53 PM »
Quote from: ELOQUINTET
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.

ELOQUINTET

  • Guest
why isn't this working!!!!!!
« Reply #12 on: August 16, 2005, 10:42:41 PM »
yeah i hear ya, bit off a little more than i can chew but hey might as well jump right in there  :shock:

ELOQUINTET

  • Guest
why isn't this working!!!!!!
« Reply #13 on: August 17, 2005, 10:16:12 AM »
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  :?

ELOQUINTET

  • Guest
why isn't this working!!!!!!
« Reply #14 on: August 17, 2005, 03:34:08 PM »
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???

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
why isn't this working!!!!!!
« Reply #15 on: August 17, 2005, 05:26:43 PM »
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.

ELOQUINTET

  • Guest
why isn't this working!!!!!!
« Reply #16 on: August 18, 2005, 09:01:46 AM »
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

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
why isn't this working!!!!!!
« Reply #17 on: August 20, 2005, 09:11:18 AM »
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.
Code: [Select]
Removed
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

daron

  • Guest
why isn't this working!!!!!!
« Reply #18 on: August 21, 2005, 11:51:28 PM »
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.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
why isn't this working!!!!!!
« Reply #19 on: August 22, 2005, 12:42:14 AM »
Quote from: daron
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.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

daron

  • Guest
why isn't this working!!!!!!
« Reply #20 on: August 22, 2005, 12:55:21 AM »
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.

ELOQUINTET

  • Guest
why isn't this working!!!!!!
« Reply #21 on: August 22, 2005, 09:21:09 AM »
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)