manddarran Posted March 30, 2010 Posted March 30, 2010 I am trying to make a routing that will label pipe based on a variable that is passed to it. I want to be able to do multiple lines/plines at a time by selecting them. I have to use mtext as I am using the stacked fractions. I have a routine that a wrote that works with regular lines, now I need it to work with poly lines. Figured I would try to modify the macalign mtext to loop but not matter what I did it gave me a syntax error. Here is the lisp that I wrote I know it is efficient, but is functional. (defun c:pipesize (); / sset item ctr check) (if (= pipesize "1/2") (setq pipesize (strcat "\\A;{\\H0.7x;\\S1#2;}" (chr 34))) ) (if (= pipesize "3/4") (setq pipesize (strcat "\\A;{\\H0.7x;\\S3#4;}" (chr 34))) ) (if (= pipesize "1/2") (setq pipesize (strcat "\\A;{\\H0.7x;\\S1#2;}" (chr 34))) ) (if (= pipesize "1") (setq pipesize (strcat "1" (chr 34))) ) (if (= pipesize "1 1/4") (setq pipesize (strcat "\\A1;1{\\H0.7x;\\S1#4;}" (chr 34))) ) (if (= pipesize "1 1/2") (setq pipesize (strcat "\\A1;1{\\H0.7x;\\S1#2;}" (chr 34))) ) (if (= pipesize "2") (setq pipesize (strcat "2" (chr 34))) ) (if (= pipesize "2 1/2") (setq pipesize (strcat "\\A2;1{\\H0.7x;\\S1#2;}" (chr 34))) ) (if (= pipesize "3") (setq pipesize (strcat "3" (chr 34))) ) (if (= pipesize "2") (setq pipesize (strcat "4" (chr 34))) ) ;(setq pipesize "\\A;{\\H0.7x;\\S3#4;}") ;(setq pipesize "1") ;load the visual lisp extensions (vl-load-com) ;check for selection ;make the remove layers if they don't exist (setq acadDocument (vla-get-activedocument (vlax-get-acad-object))) (setq theLayers (vla-get-layers acadDocument)) (setq newLayer (vla-add theLayers "f-text")) ;done makeing new layers (princ) ;get the selection set (setq pt (osnap (getpoint "Select Pipe and Text location") "near")) (while (NOT (NULL PT)) (setq sset (ssget pt)) ;set up the counter (setq ctr 0) ;count the number of entities and loop (setq item (ssname sset ctr)) ;convert to vl object (setq item (vlax-ename->vla-object item)) ;check to see what type of entity it is. (if (= "AcDbLine" (vla-get-ObjectName item)) ;change the lines layer (setq ang (vlax-get-property item 'Angle)) );if (if (= "AcDbLine" (vla-get-ObjectName item)) ;change the lines layer (setq ang (vlax-get-property item 'Angle)) );if ;increment the counter (setq dist (* 1 scalem)) (setq ang2 (+ ang (/ pi 2))) (setq pt2 (polar pt ang2 dist)) (setq ang (rtd ang)) (princ "\n") (princ ang) (cond ((and (>= ang 45) (< ang 135)) (setq ang 90)) ((and (>= ang 135) (< ang 225)) (setq ang 0)) ((and (>= ang 225) (< ang 315)) (setq ang 90)) ((or (>= ang 315) (< ang 45)) (setq ang 0)) ) (setq ang2 (dtr ang)) (setq ang2 (+ ang2 (/ pi 2))) (setq pt2 (polar pt ang2 dist)) (command "-mtext" pt2 "j" "mc" "R" ang "w" "90" pipesize "") (princ) (setq pt (osnap (getpoint "Select Pipe and Text location") "near")) ) );defun Quote
sroberts Posted April 6, 2010 Posted April 6, 2010 Hello I don't know if this is what your looking for but it sure helped me out a lot. It will label the line with the name of your layer so I named my layer the size of the pipe. And a big thank you to everyone in this site who help me. Sherry http://www.cadtutor.net/forum/showthread.php?p=288453#post288453 Quote
manddarran Posted April 6, 2010 Author Posted April 6, 2010 Yeah I went thru them all and none just seems to work just right. I simply need to place some mtext at a line/pline and do it multiple times. All the nice routines only place on text or default to placing mid point of line. thx! Quote
Lee Mac Posted April 6, 2010 Posted April 6, 2010 What exactly are you looking to align? Would the user select a pipesize then multiple lines? I could see what I could do Quote
Lee Mac Posted April 6, 2010 Posted April 6, 2010 You might also want to check out this more advanced option, using the object Xdata Quote
manddarran Posted April 6, 2010 Author Posted April 6, 2010 That is exactly what I am trying to do. I select a "button" and then you can select multiple lines and it places it above or to the left of the line. The routine I wrote works well except not with anything but lines. My routine is rudimentary and the comments are off as I have copied and pasted and modified....it also uses some custom variables, but If I could get something that just places mtext above line or pline etc multiple times by selecting the lines, I can make it work with our systems. We have to us mtext as we are stacking fractions. The first part of my lisp sets that mtext to be placed and away it goes. On a side note, I have been using/modifying alot of your routines and really appreciate the time and effort that you have put into all that work. Thanks again, Matt Quote
manddarran Posted April 6, 2010 Author Posted April 6, 2010 You might also want to check out this more advanced option, using the object Xdata I messed with that one as well. I like the way it attaches, but when ever I tried to "loop" that program it moved the text instead of adding another instance. If this could loop and dynamically move, that would be the cat's meow. Also I am not sure that this was mtext, I looked at so many my brain is a blur. Quote
Lee Mac Posted April 6, 2010 Posted April 6, 2010 Thanks for your compliments, I appreciate it The last routine can do both, but I don't particularly want to modify it, I shall see what I can do with MacAlign Quote
manddarran Posted April 6, 2010 Author Posted April 6, 2010 Thanks for your compliments, I appreciate it The last routine can do both, but I don't particularly want to modify it, I shall see what I can do with MacAlign I will take a look at that one again.... You have a donate button so I can buy you a brew? Quote
Lee Mac Posted April 6, 2010 Posted April 6, 2010 You have a donate button so I can buy you a brew? I used to, but they were removed a little while ago - I'll PM you Quote
alanjt Posted April 6, 2010 Posted April 6, 2010 You have a donate button so I can buy you a brew? https://www.paypal.com/us/cgi-bin/webscr?cmd=_flow&SESSION=qzSoG20bVUKMA9UsUdt55KvYGD2fjWO3ZCM1ZVQJVtpomwJmsO3vCPboOc4&dispatch=5885d80a13c0db1f059ee17e99acf195b5f3a4b6a78dddb4b1b86ec4390bd9bd :wink: Quote
Lee Mac Posted April 7, 2010 Posted April 7, 2010 Hi Matt, Give the attached a go - it should also work on nested entities (i.e. lines within a block etc). Lee PS> I gotta come up with better names for these things... MacPipe.lsp Quote
manddarran Posted April 7, 2010 Author Posted April 7, 2010 Man that was fast, I will give it a whirl! Quote
manddarran Posted April 7, 2010 Author Posted April 7, 2010 Wholly schinzle....that thing is slick! Works perfect! On top of that that thing as a bunch of stuff I can use in my other lisp routines! Quote
Lee Mac Posted April 7, 2010 Posted April 7, 2010 Wholly schinzle....that thing is slick! Works perfect! Excellent Quote
Lee Mac Posted April 7, 2010 Posted April 7, 2010 On top of that that thing as a bunch of stuff I can use in my other lisp routines! Happy to help, (as long as due credit is given for the snippets ) Quote
manddarran Posted April 7, 2010 Author Posted April 7, 2010 Happy to help, (as long as due credit is given for the snippets ) With out a doubt! I must know, how long did it take you to write that? Quote
Lee Mac Posted April 7, 2010 Posted April 7, 2010 With out a doubt! I must know, how long did it take you to write that? About 20 mins this morning - I've written many similar programs, so it was only a matter of how fast I could type (not trying to sound arrogant). Quote
manddarran Posted April 7, 2010 Author Posted April 7, 2010 About 20 mins this morning - I've written many similar programs, so it was only a matter of how fast I could type (not trying to sound arrogant). That was what I figured. I have been trying to do that for two days. I only get to dable in lisp when I get the time so I forget everything that I have done in the past.. Quote
Lee Mac Posted April 7, 2010 Posted April 7, 2010 I'll admit, I'm a bit addicted to writing them - I should imagine there are a few others on here who also perhaps spend a bit too much time writing them... Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.