×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Labels connected to Linework

Labels connected to Linework

Labels connected to Linework

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

RE: Labels connected to Linework

Can you provide us with a picture of what it is you are trying to accomplish?

RE: Labels connected to Linework

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

RE: Labels connected to Linework

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

RE: Labels connected to Linework

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources