Edit attribute value with lisp when inserting with Mleader

Edit attribute value with lisp when inserting with Mleader

jjcrocco
Enthusiast Enthusiast
1,280 Views
4 Replies
Message 1 of 5

Edit attribute value with lisp when inserting with Mleader

jjcrocco
Enthusiast
Enthusiast

I have a lisp that uses the standard Mleader command, then changes it to a text layer automatically.

The below works perfectly for the regular Mleader with text.

 

I have created an mleader STYLE with a tag that has a few attributes.

It inserts the leader and tag, but hangs on editing the attributes.  Then after hitting enter, it completes to change it to the text layer. it then needs to be double clicked on to edit the attributes.

 

What I would like is to run the leader, then enter the text into the attribute box, then it finishes and changes layer.

I would even accept it to insert it first, change layer, then bring up attribute box to edit.

I cant even seem to get this to work either way.

 

Any ideas or help is appreciated.

 

;allows mleader to be used and changed automatically to text layer
;
(defun c:mleader-cke-TEST ()
  (initcommandversion)
  (command "_.mleader")
  (while (> (getvar 'cmdactive) 0)(command pause))
  (c:c2textlyr)
)

0 Likes
1,281 Views
4 Replies
Replies (4)
Message 2 of 5

Jonathan3891
Advisor
Advisor

I didnt have any problems with it hanging up on editing the attributes. Can you attach a sample drawing?

 

I learned long ago that its best to have the lisp check if the layer exist and if not create it. That way if the layer isnt there, the lisp will still run.

There are multiple ways to accomplish that, but this is simple enough. You will need to change the layer name, color, etc.

(defun c:test (/ olayer)
  (setq olayer (getvar 'clayer)) ;remember current layer
  (if (not (tblsearch "layer" "c_gen_Dimn")) ;check to see if layer exist if not create it
  (command "_.layer" "m" "c_gen_Dimn" "c" "132" "" "") 	;create layer
  (setvar "clayer" "c_gen_Dimn") ;set new layer current
 )
 (initcommandversion)
 (command "_.mleader")
 (while (> (getvar 'cmdactive) 0)(command pause))
  (setvar 'clayer olayer) ;return to previous layer
  )

Jonathan Norton
Blog | Linkedin
0 Likes
Message 3 of 5

jjcrocco
Enthusiast
Enthusiast

The block that has the attributes is EQ.  I have attached it here.  You have to create an Mleader style that uses this block. that will create where I am with it.

AS for the layer, thank you, and I do have that in my lisp as shown below, which is ran from the lisp I am working on, as well as others of similar nature.

Let me know what you figure out.

 

;Custom commands by John Crocco    1-15-02
;changes last item in drawing to the proper text layer depending on the current layer setting.
;IE: if on hvacn layer, drawing a leader will change it to the hvact layer.
;
(DEFUN C:c2textlyr (/ ldr)
 (setq Ldr (SSGET "L"))
 ;(command "change" ldr "" "p" "la" (GetTextLayer) "" )

(setq layer (gettextlayer))

(if (not (tblsearch "layer" layer))
 (command "_.layer" "_N" layer "_C" "1" layer "")
      (command "_.chprop" "LAST" "" "_C" "red" "");;;;added
)

(command "._Change" ldr "" "_p" "_la" (gettextlayer) "" )

)

0 Likes
Message 4 of 5

Ranjit_Singh
Advisor
Advisor

Maybe set the layer first, insert the mleader, pass the attributes and then set back the current layer

(defun c:mleader-cke-test  ( / curlay)
 (setq curlay (getvar 'clayer))
 (command "._-layer" "_m" "mleader-layer" ""); change layer name to your layer
 (command "_.mleader" pause)
 (setvar 'clayer curlay))

Mleader.gif

 

Message 5 of 5

jjcrocco
Enthusiast
Enthusiast

That is an interesting way to do it, I can work on it that way and see.

Will let you know.

Thank you.

0 Likes