Jump to content

Recommended Posts

Posted

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

  • Replies 20
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    9

  • manddarran

    9

  • alanjt

    2

  • sroberts

    1

Top Posters In This Topic

Posted Images

Posted

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!

Posted

What exactly are you looking to align? Would the user select a pipesize then multiple lines?

 

I could see what I could do :)

Posted

You might also want to check out this more advanced option, using the object Xdata :)

Posted

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

Posted
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.

Posted

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

Posted
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?

Posted
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 :)

Posted

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... o:)

MacPipe.lsp

Posted

Man that was fast, I will give it a whirl!

Posted

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!

Posted
Wholly schinzle....that thing is slick! Works perfect!

 

Excellent :)

Posted
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 :P )

Posted
Happy to help, (as long as due credit is given for the snippets :P )

 

With out a doubt! I must know, how long did it take you to write that?

Posted
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).

Posted
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..

Posted

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...

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...