Author Topic: Trouble inserting text to endpoint of a line in a block  (Read 1329 times)

0 Members and 1 Guest are viewing this topic.

jlogan02

  • Bull Frog
  • Posts: 327
Trouble inserting text to endpoint of a line in a block
« on: March 05, 2018, 11:10:24 AM »
The code below is run by selecting a button where the Revision_Blk is inserted into the drawing by user selected point The border this text is inserted into is a block that cannot be exploded and the layers are locked.

The image (not sure if it's posting) shows the insertion points of two of these "starter" revision text insertions. The first horizontal grey line just below the word REVISION is part of the border block. When a user goes to insert the text on the endpoint of this line, the "TextEdit" command is issued without a problem.

Time passes in the life of the drawing and the user needs to add a second revision using the same process. Only this time when he selects the line that is at the bottom of the first revision (lower red circle in image) he has to hit an enter for the "TextEdit" command to fire rather than it firing after selecting the endpoint.

As you can see in my code I've created a work around where I turn the block layer off and on between the insertion and the textedit. It works this way, but I can see a user wondering why the border disappears unexpectedly.

Why the difference?

Code: [Select]
;;
;;Inserts Revision History text
;;1/10/2018 Jerry Logan - Idaho Power Inc.
;;Updated: Included repeat for textedit
;;
(defun c:Revision_Blk (/ Cosmode Cecho pt1 pt2 dim)
 (defun *error* (msg)
    (if osmode
      (setvar 'osmode osmode)
    )
    (if cmdecho
      (setvar 'cmdecho cmdecho)
    )
    (cond ((not msg))                                                   ; Normal exit
          ((member msg '("Function cancelled" "quit / exit abort")))    ; <esc> or (quit)
          ((princ (strcat "\n** Error: " msg " ** ")))                  ; Fatal error, display it
    )
    (princ)
  )

  ;;Store system variables
(setq Cosmode (getvar 'osmode))
(setq Cecho (getvar 'cmdecho))

  ;;Set system variables
  (setvar 'cmdecho 0)
  (setvar 'osmode 1)

  (setq pt1 '(29.5 22.5)
pt2 '(34.5 5.5)
  )
  (setq dim (getvar 'dimscale)
pt1 (mapcar '* pt1 (list dim dim))
pt2 (mapcar '* pt2 (list dim dim))
  )

  ;;(command "osnap" "endpoint")
  ;;(command "._layer" "OFF" "TBLK_BORD_LINES" "")
  (command "._zoom" "w" pt1 pt2 "")
  (command "._insert" "Revision Block" pause dim dim "")
  (command "._explode" "_l")
  ;;(command "._layer" "ON" "TBLK_BORD_LINES" "")
  (if (and (setq ss (ssget))
   (setq i -1)
      )
    (repeat (sslength ss)
      (setq hnd (ssname ss (setq i (1+ i))))
      (command "_textedit" hnd)
    )
  )

  ;;Restore system variables
  (setvar 'osmode Cosmode)
  (setvar 'cmdecho Cecho)

  (*error nil)
  (princ)
)
J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10

ChrisCarlson

  • Guest
Re: Trouble inserting text to endpoint of a line in a block
« Reply #1 on: March 05, 2018, 11:16:55 AM »
Try adding the following into your insertion line, before the location.

Code - Auto/Visual Lisp: [Select]
  1. "_non"

jlogan02

  • Bull Frog
  • Posts: 327
Re: Trouble inserting text to endpoint of a line in a block
« Reply #2 on: March 05, 2018, 12:53:48 PM »
Thanks Master_Shake.

In all my testing I was picking the intersection of the horizontal and vertical lines.

Code - Auto/Visual Lisp: [Select]
  1. "_end"
[/color]

Worked once I started selecting just the horizontal grey line. I tried "_non" earlier and it was working the whole time, but my understanding of how it was supposed to work was wrong.

Thanks again.

JLogan

J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10