Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Labels connected to Linework

Status
Not open for further replies.

mstg007

Civil/Environmental
Jun 2, 2003
40
Is there a lisp or away to connect labels to linework.

So if i have linework on a concrete layer, it will randomly place a label to that linework saying Concrete.

Hopefully that makes sense.

or

If there is a way to select a linework and you manually place the lable where ever.

thanks
 
Replies continue below

Recommended for you

Can you provide us with a picture of what it is you are trying to accomplish?
 
I want to select a line which is on layer "EX_Concrete". Then it prompts for a leader line and you select where you want it, then it puts text next to the leader line saying "EX_Concrete" or Existing Concrete".

And can we make a generic leader line that automatically prompts for text after the leader is drawn?

thanks
 
Hi,
I think I saw your post on the tektips forums also. I pieced this program from bits of other ones. See if this gets you close. It has a little bug where your initial pick point has to be pretty close to where you want it to start but should work ok.

(defun C:LABEL_PROP ( / ENT ENT1 LYR PT PT1 PT2 QUA TXTENT TXTINS TXTSZ)
(setq ENT1 (entsel)
ENT (car ENT1)
PT1 (car (cdr ENT1))
PT (strcat (rtos (car PT1)) "," (rtos (cadr PT1)))
LYR (cdr (assoc 8 (entget ENT))) ;LAYER NAME PROPERTY
)
(setvar "CMDECHO" 0)
(princ "\nSelect Placement Point: ")
(command "_.LINE" PT PAUSE "")
(setq PT2 (getvar "LASTPOINT")
QUA (CalcQuadrant PT1 PT2)
TXTSZ (getvar "TEXTSIZE")
PT1 (strcat (rtos (+ (car PT2) (/ TXTSZ 4)))
","
(rtos (+ (cadr PT2) (/ TXTSZ 4)))
)
)
(command "-text" PT1 "" "" LYR)
(setq TXTENT (entget (entlast))
TXTINS (GetTxtInsPt QUA TXTENT PT2))
;------------------------------------------------------------------------------
;Update text insert point, assumes lower left text inserts
;------------------------------------------------------------------------------
(setq TXTENT(entmod (subst (cons 10 TXTINS) (assoc 10 TXTENT)TXTENT)))
(setq PT (strcat (rtos (car PT2))","(rtos (- (cadr PT2) (* TXTSZ 0.75))))
PT1 (Get2ndRectCorner QUA TXTENT PT2)
PT1 (strcat (rtos (car PT1))","(rtos (cadr PT1)))
)
(command "_RECTANGLE" PT PT1)
(princ "\n")
)
;------------------------------------------------------------------------------
;GetTxtInsPt: Return point based on text height and quadrant of leader. Uses
; text bounding box to help calculate where.
;Arguments: Quadrant 1,2,3,4 based on CalcQuadrant function; text entity; point
; to calculate from.
;Returns: Point
;------------------------------------------------------------------------------
(defun GetTxtInsPt (QUAD TXTENT PT / BOX TXTINS TXTSZ TXTWIDTH YPT)
(setq BOX (textbox TXTENT)
TXTWIDTH (-(caadr BOX)(caar BOX))
TXTSZ (getvar "TEXTSIZE")
YPT (cons(-(cadr PT)(/ TXTSZ 2))(list 0.0))
)
(cond
((or (= QUAD 1)(= QUAD 4))
(setq TXTINS(cons(+(/ TXTSZ 2)(car PT))YPT)))
(1
(setq TXTINS(cons(- (car PT)(+(/ TXTSZ 2)TXTWIDTH))YPT)))
) ;cond
TXTINS
)
;------------------------------------------------------------------------------
;Get2ndRectCorner: Return point based on text height and quadrant of leader.
; Uses text bounding box to help calculate where.
;Arguments: Quadrant 1,2,3,4 based on CalcQuadrant function; text entity; point
; to calculate from.
;Returns: Point
;------------------------------------------------------------------------------
(defun Get2ndRectCorner (QUAD TXTENT PT / BOX RECINS TXTSZ TXTWIDTH YPT)
(setq BOX (textbox TXTENT)
TXTWIDTH (-(caadr BOX)(caar BOX))
TXTSZ (getvar "TEXTSIZE")
YPT (cons(+(cadr PT)(* TXTSZ 0.75))(list 0.0))
)
(cond
((or (= QUAD 1)(= QUAD 4))
(setq RECINS(cons(+(car PT) TXTSZ TXTWIDTH)YPT)))
(1
(setq RECINS(cons(-(car PT) TXTSZ TXTWIDTH)YPT)))
) ;cond
RECINS
)
;------------------------------------------------------------------------------
;CalcQuadrant: Return quadrant direction between 2 points.
; Quadrants are 3oclock to 12oclock as 1, 12oclock to 9 oclock as 2
; 9oclock to 6oclock as 3, and 6oclock to 3oclock as 4
;Arguments: PT1 is starting point, PT2 is ending point
;Returns: Quadrant as integer
;------------------------------------------------------------------------------
(defun CalcQuadrant (PT1 PT2 / QUAD)
(if (<= (car PT1)(car PT2)) ;Quadrant 1 or 4
(if (<= (cadr PT1)(cadr PT2))
(setq QUAD 1)
(setq QUAD 4)
)
(if (<= (cadr PT1)(cadr PT2))
(setq QUAD 2)
(setq QUAD 3)
) ;if
) ;if
QUAD
)



Whether you think that you can, or that you can't, you are usually right
.. Henry Ford
 
hey it makes plunty of sense, I did get it to load up, and did find some bugs... I am able to select an object, then the leader comes out, and i can tell the leader where to end, but it fails with the placement of the layer name...
Command: LABEL_PROP

Select object:
Select Placement Point: Unknown command "EX-SIGNS". Press F1 for help.
; error: bad argument type: numberp: nil

Thank you for your help!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor