Please help me to write a lisp for attribute substation

Please help me to write a lisp for attribute substation

Sunny2006
Enthusiast Enthusiast
700 Views
7 Replies
Message 1 of 8

Please help me to write a lisp for attribute substation

Sunny2006
Enthusiast
Enthusiast

I have a Mleader block with  3 ATTRIBUTES

1 = TOP (USER GIVEN)

2= MIDDLE ( USER GIVEN / 2)

3 = BOTTOM ( USER GIVEN / 4)

Once the user enters by lisp  value-1

it comes in Mleader WITH CALCULATED ALL 3 attributes. is that possible? 

0 Likes
701 Views
7 Replies
Replies (7)
Message 2 of 8

Kent1Cooper
Consultant
Consultant

Do you mean substitution?  If so, I assume you are talking about a Block that is already Inserted, and you want to select it and substitute different values into its Attributes.  For example, in simplest terms, something like this [minimally tested]:

 

 

It can be made to check that what you selected is a Block with the right Attributes in it, and can get the usual enhancements [Undo begin/end wrapping, etc.].

Of course, it may be just as easy to simply select the Block and change the Attribute values in the Properties palette.

If I have misunderstood what you want to do, explain in more detail, particularly the starting conditions and anticipated User steps.

[Never mind -- it looks like Message 1 has been edited since I started a reply, and it's not asking for what I assumed.  I would need to think about it -- Attributes in MultiLeader Blocks work differently than in top-level Blocks.]

Kent Cooper, AIA
0 Likes
Message 3 of 8

Kent1Cooper
Consultant
Consultant

I'm confused.  I don't think you're using Attributes correctly.  The constant wordings "TOP=" and "MID=" and "BOT=" should be Text, and the others can be Attributes, but their Tags should not be the same as their values.  If you give it a TOP value of 8, you don't want the MID value of 4 to be under a "6MTR" Tag.  And for what you want to do, I think the "MTR" parts should also be Text, and only the numerical parts should be Attributes, which will be less work for a substitution routine.

 

Also, your numerical parts disagree with your description.  Either the top one should be 12 [not 1.2] or the others should be 0.6 and 0.3 [not 6 and 3].

Kent Cooper, AIA
0 Likes
Message 4 of 8

smallƑish
Advocate
Advocate

No need to complicate with attributes. Make it very simple with mleader.

smallish_0-1703441414179.gif

 

 

(defun c:TMB ( / TOP MID BOT p)
  (setq TOP (getreal "\nEnter TOP: "))
  (setq MID (/ TOP 2))
  (setq BOT (/ TOP 4))
  
  (setq p (getpoint "\nSpecify leader landing point: "))
  
  (vl-cmdf "_.MLEADER"
           "_none"
           "_none" p
           "_none" (polar p (/ pi 4) 200)
           (strcat "TOP: " (rtos TOP 2 2) "Mtr" "\nMID: " (rtos MID 2 2) "Mtr" "\nBOT: " (rtos BOT 2 2) "Mtr")
  )
)

 

 

 

0 Likes
Message 5 of 8

Sunny2006
Enthusiast
Enthusiast

My Mleader does not have this box !

0 Likes
Message 6 of 8

smallƑish
Advocate
Advocate

Try <this>

0 Likes
Message 7 of 8

Sunny2006
Enthusiast
Enthusiast

I want to choose mleader insertion and landing point by myself, not automated, What to do for that?

0 Likes
Message 8 of 8

sofiaisadoravega
Explorer
Explorer

Its very easy 

 

(setq p1 (getpoint "\nSpecify leader starting point: "))
(setq p2 (getpoint p1 "\nSpecify leader landing point: "))

 

(defun c:TMB ( / TOP MID BOT p)
  (setq TOP (getreal "\nEnter TOP: "))
  (setq MID (/ TOP 2))
  (setq BOT (/ TOP 4))
  
  (setq p1 (getpoint "\nSpecify leader starting point: "))
  (setq p2 (getpoint p1 "\nSpecify leader landing point: "))
  
  (vl-cmdf "_.MLEADER"
           "_none"
           "_none" p1
           "_none" p2
           (strcat "TOP: " (rtos TOP 2 2) "Mtr" "\nMID: " (rtos MID 2 2) "Mtr" "\nBOT: " (rtos BOT 2 2) "Mtr")
  )
)
0 Likes