Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Lisp routine to increment attribute in a block used with Mleader

13 REPLIES 13
SOLVED
Reply
Message 1 of 14
ItBeatsMe
4848 Views, 13 Replies

Lisp routine to increment attribute in a block used with Mleader

Hi,

 

I have no knowledge in Lisp so I would like to ask if someone could help me with below.

 

I use Mleader command with a block.

The block is a circle with a horisontal line from quadrant to quadrant.

Above the line I have an attribute for a number and below the line I have another attribute for another number.

 

What I would like to do is to get a function where I could set the upper number to a fixed number e.g. 11 while the lower number I would like to be incremented and I would like to set a range e.g. 55-60 and the Mleader command runs until it reaches the end of the range, so I can put as in this example 6 separate leaders that automatically increment the lower attribute number. So the leaders would then show (upper number/lower number) as follows: 11/55, 11/56, 11/57, 11/58, 11,59, 11/60 then the command ends.

 

Would this be possible?

 

Thanks in advance for any help.

13 REPLIES 13
Message 2 of 14
3wood
in reply to: ItBeatsMe

Please try attached INNB.vlx which can do exactly what you want, except that it doesn't stop (in your example, 60) until you exit from it.

 

 

Message 3 of 14
ItBeatsMe
in reply to: 3wood

I have two tags and the comman only allows to change one of the tags.

----------------------------

Command:  INNB

 

Select object:

2 attributes in selected block:

No.  TAG

1.   NR

2.   NR

Which attribute to be used? <1>:

-----------------------------

 

I would like to set tag no 1 to 11 and tag no 2 to be incremental from a starting number I input. e.g starting number 55 that increments up to 60.

It would also be great if one could run the command as the regular Mleader command asking me to pick the arrow point and the endpoint of the leader i.e. where the block (circle) is placed.

 

Below is an example picture of how I want it to look like.

Image1.jpg

 

Message 4 of 14
3wood
in reply to: ItBeatsMe

Just insert a tag with the first attribute set to 11, then use INNB to pick up that tag.

Message 5 of 14
ItBeatsMe
in reply to: 3wood

OK to be more detailed as I need the command to work differently and more flexible.

 

This is how I work with Mleader command.

I start Mleader command and insert the arrow point ant then the point where the leader block i.e. the circle with the two attribute tags should be placed, then the command asks me to enter the number for the upper attribute number and the lower attribute number. This is the procedure for every Mleader I add to the drawing.

 

The upper number is a house location number and the lower number is a number that will be incremental but start at either 100, 200, 300 and up to 900 depending upon the type of item that is defined by the series of hundreds. (100=Golden Bars, 200=Diamonds, 300=Rubies, just kidding 🙂 ).

 

So lets say I begin with house number 1, then I start Mleader and put it on the drawing with arrow position and leader block position and type in upper number 1, then 100 as requested from the command. 

Next Mleader same procedure 1 for upper number, but now I type in 101 for the lower number.

I carry on until I have added all items (100 and forward) in house 1.

Next phase is to add the items we label in series from starting number 200, (incremented), but still in house location 1, so it would be 1/200, 1/201 and forward.

Then when house location 1 is finished, I move on with house location 2 and label the items within house 2 with the Mleader command, so it would be like: 2:101, 2: 102....., 2:201, 2:202,......2:301, 2:302......., 2:401, 2:402, 2:403.........and so on.........

 

The lower number is in average incremental up to 65 items per series of hundreds for each house, so you can imagine there are lots of manual work with this procedure typing in the values, and that's what I wanted to make more automatic, by beeing able to set the house number (upper numer) and have the lower number automatically incremented within the Mleader command as I need to be able to place the arrow point at the specific item and find a free space for the block circle containing the house number(upper) and the item ref. number (lower).

 

Message 6 of 14
pbejse
in reply to: ItBeatsMe

Do you have a fix number leader points? is it always two or sometimes 3 points? Or do you use a specific Mleader style? what about the block? is that a "user" type block or the "detail callout" block?

 

Message 7 of 14
pbejse
in reply to: pbejse


@pbejse wrote:

Do you have a fix number leader points? is it always two or sometimes 3 points? Or do you use a specific Mleader style? what about the block? is that a "user" type block or the "detail callout" block?

 


This code does NOT have any error checking. Conditions are current Mleader style has max of 2 points and use block for multileader type and has two attributes [regardless if user or "detail callout" block]

 

(defun c:Mlt (/ _getint p1 p2 p3)
;;;	pBe 26Jan2014	;;;
(defun _getint (def msg)
(cond  ((getint  (strcat msg
                  (if def (strcat " <" (itoa def)  ">: ") ": ") )))
                        (def)))      
(foreach Var '(("tag1" 100) ("tag2Start" 10) ("tag2Max" 15))
(if (null (eval (setq v (read (car var)))))
    	(set v (cadr var)))	      
      )
 
          (setq tag1 (_getint tag1 "\nEnter House Number"))
     	  (setq tag2Start (_getint tag2Start "\nEnter starting number"))
      	  (While (<= (setq tag2Max
                                (_getint
                                      tag2Max
                                      "\nEnter end of the range,"))
                     tag2Start)
                (princ "\nEnter Value greater than Start number"))
  (while  (and (<= tag2Start tag2Max)
                   (setq p1 (getpoint "\nPick Target point "))
                   (setq p2 (getpoint p1 "\nSpecify next point: "))
                   )
            (command "_mleader" "_non" p1 "_non" p2 
                  (itoa tag1) (itoa tag2Start))
            (setq tag2Start (1+ tag2Start)))
      (princ)
      )

 

HTH

Message 8 of 14
3wood
in reply to: ItBeatsMe

I reckon INNB is exactly what you need.

Otherwise, you can insert a mleader first with the house number and initial lower number, copy this block to desired places, then use attached ALTEXT.vlx to increase selected number in a sequence.

 

Message 9 of 14
phanaem
in reply to: ItBeatsMe

This is a very simple way to create mleaders as you described...

BUT it works OK only if Mleader command version [prompt] is as you mentioned: point->point->attribute1->attribute2

 

(defun C:MLINC ( / att1 att2 p1 p2)
(setvar 'cmleaderstyle "YourStyleHere"); add your mleaderstyle (while (setq att1 (getint "\nTAG1 value: ")) (if (setq att2 (getint "\nTAG2 start value: ")) (while (setq p1 (getpoint "\nSpecify leader arrowhead location: ")) (if (setq p2 (getpoint "\nSpecify leader landing location: " p1)) (progn (vl-cmdf "MLEADER" p1 p2 (itoa att1) (itoa att2)) (setq att2 (1+ att2)) ) ) ) ) ) (princ) )

 

Also you can "force" Mleader command to run as you wish, but is a very unprofessional way and so I'll give it just as a note:

 

 (vl-cmdf "MLEADER" "H") ; force mleader to ask for arrowhead first
  (while (> (getvar 'cmdactive) 0)
    (vl-cmdf "1,1")
    )
  (entdel (entlast))

The command version is saved between autocad sessions, so it must be saved somewhere in the registry.

It is not a sysvar nor an environment variable.

I found a key that keeps mleader creation mode, but this is saved just when autocad is closed.

(vl-registry-read  (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Profiles\\AutoCAD\\MLeader") "CreatedMode")

Maybe someone else knows where to look; I had no luck.

 

Message 10 of 14
Lee_Mac
in reply to: phanaem


@phanaem wrote:

The command version is saved between autocad sessions, so it must be saved somewhere in the registry.

Maybe someone else knows where to look; I had no luck.


I've also spent some time looking for this setting to no avail...

But I like your workaround to force some kind of consistency with the command - good thinking Stefan.

 

Lee

Message 11 of 14
ItBeatsMe
in reply to: pbejse

The arrow point and leader point varies for ecah leader. The arrow point is different every time as the item location is always different, the leader point is different as to where I find a space which is not interferring any wall sections of the house (top view) but could stilll be placed inside the room itself where the item is if the space is available.

 

I use a specific Mleader style that uses a User Block I have created, and the User Block is a circle with a line from quadrant to quadrant of the circle i.e. 9 o'clock to 3 o'clock and above the line is my attribute tag nr 1 for the house number and below the line is the attribute tag nr 2 for the item number (which I wanted to be incremetal)

 

I see there are more following answers to this subject, which I will check when back at work as I don´t have AutoCad at home. But I am already thrilled with excitement from the answers as I hope one of them will be a brake through.

 

I'll update you on my findings, once tested.

Message 12 of 14
pbejse
in reply to: ItBeatsMe


@ItBeatsMe wrote:

The arrow point and leader point varies for ecah leader. The arrow point is different every time as the item location is always different, the leader point is different as to where I find a space which is not interferring any wall sections of the house (top view) but could stilll be placed inside the room itself where the item is if the space is available. 

 


Got all that ItBeatsMe, the "points" i'm refering to is the "Maximum leader points" value.

 

That is why the "MleaderStyle" needs to be defined [as noted by Stefan]. This will avoid problems dealing with the numerous settings of a Mleader Style.

 

Try the codes and tell us what you think.

 

pBe

 

BTW System variables settings is as folows 

Attida = 0

Attreq = 1

Have not incorporated those on the rouitne as of yet.

 

Message 13 of 14
phanaem
in reply to: Lee_Mac


@Lee_Mac wrote:

@phanaem wrote:

The command version is saved between autocad sessions, so it must be saved somewhere in the registry.

Maybe someone else knows where to look; I had no luck.


I've also spent some time looking for this setting to no avail...

But I like your workaround to force some kind of consistency with the command - good thinking Stefan.

 

Lee


Thank you Lee. I would like to be another way; it's very frustrating when it happens.

 

 

@pBe: Good point. Attdia and Attreq should be considered in any case.

Message 14 of 14
ItBeatsMe
in reply to: pbejse

Awesome, thanks both pbejse and phanaem, it works perfect and exactly the way I wanted. Big Thanks!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost