Dynamic block Visibility Value to a MULTI LEADER

Dynamic block Visibility Value to a MULTI LEADER

3arizona
Advocate Advocate
1,720 Views
10 Replies
Message 1 of 11

Dynamic block Visibility Value to a MULTI LEADER

3arizona
Advocate
Advocate

Hi, i found this lisp on another forum but didn't have much luck getting help.  Hope someone can help me as this will eliminate a bunch of block from my drawings. From all of the lisps i found, this is the closest one that shows what i want to accomplish.  Thanks

 

i have a fastener dynamic block with two invisible attributes, state-1 and state-2. the only difference in the block visibility is a washer. States show value text with a link to a dimension within block to show size of fastener if stretched (#12 - 1 1/2" HWH-SD-TEK). lisp work fine but mleader shows both state-1 and state-2.

 

If possible this is what i want lisp to do:

  1. Read only current dynamic block viability state value.
  2. Mleader to update if its toggled from state-1 to state-2 (show only current state value)
  3. Can you remove state-2 from lisp if above can be accomplished.
  4. Is there too much necessary stuff in lisp for my use. i only use this in Model Space?

 

(defun c:mlb ( / at1 at2 ent enx ins lst mld pnt )
    (while
        (progn
            (setvar 'errno 0)
            (setq ent (car (entsel "\nSelect block <exit>: ")))
            (cond
                (   (= 7 (getvar 'errno))
                    (princ "\nMissed, try again.")
                )
                (   (null ent)
                    nil
                )
                (   (/= "INSERT" (cdr (assoc 0 (setq enx (entget ent)))))
                    (princ "\nObject is not a block.")
                )
                (   (/= 1 (cdr (assoc 66 enx)))
                    (princ "\nBlock is not attributed.")
                )
                (   (not
                        (and
                            (setq lst (vlax-invoke (vlax-ename->vla-object ent) 'getattributes)
                                  lst (mapcar '(lambda ( x ) (cons (strcase (vla-get-tagstring x)) x)) lst)
                            )
                            (setq at1 (cdr (assoc "STATE-1" lst)))
                            (setq at2 (cdr (assoc "STATE-2" lst)))                            
                        )
                    )
                    (princ "\nBlock does not contain "sate-1\" & \"sate-2\" attributes." at )
                )
                (   (setq ins (cdr (assoc 10 enx))
                          pnt (getpoint (trans ins ent 1) "\nPick leader endpoint <exit>: ")
                    )
                    (setq mld
                        (vlax-invoke
                            (vlax-get-property (LM:acdoc)
                                (if (= 1 (getvar 'cvport))
                                    'paperspace
                                    'modelspace
                                )
                            )
                            'addmleader
                            (append (trans ins ent 0) (trans pnt 1 0))
                            0
                        )
                    )
                    (vla-put-textstring mld
                        (strcat
                            "%<\\AcObjProp Object(%<\\_ObjId "
                            (LM:ObjectID at1)
                            ">%).TextString>% - %<\\AcObjProp Object(%<\\_ObjId "
                            (LM:ObjectID at2)
                            ">%).TextString>%"
                        )
                    )
                    (vla-put-textrotation mld 0.0)
                    (if (<= (car pnt) (car (trans ins ent 1)))
                        (progn
                            (vla-setdoglegdirection mld 0 (vlax-3D-point (trans '(-1.0 0.0) 1 0 t)))
                            (vlax-invoke mld 'setleaderlinevertices 0 (append (trans ins ent 0) (trans pnt 1 0)))
                        )
                        (vla-setdoglegdirection mld 0 (vlax-3D-point (trans '(1.0 0.0) 1 0 t)))
                    )
                    (vla-regen (LM:acdoc) acactiveviewport)
                    t
                )
            )
        )
    )
    (princ)
)
   
;; ObjectID  -  Lee Mac
;; Returns a string containing the ObjectID of a supplied VLA-Object
;; Compatible with 32-bit & 64-bit systems
 
(defun LM:ObjectID ( obj )
    (eval
        (list 'defun 'LM:ObjectID '( obj )
            (if
                (and
                    (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE"))
                    (vlax-method-applicable-p (vla-get-utility (LM:acdoc)) 'getobjectidstring)
                )
                (list 'vla-getobjectidstring (vla-get-utility (LM:acdoc)) 'obj ':vlax-false)
               '(itoa (vla-get-objectid obj))
            )
        )
    )
    (LM:ObjectID obj)
)

 

0 Likes
1,721 Views
10 Replies
Replies (10)
Message 2 of 11

pbejse
Mentor
Mentor

@3arizona wrote:

Hi, i found this lisp on another forum but didn't have much luck getting help. 

 

 For starters, that is not best way to start a discussion @3arizona . Makes me wonder what you have to say about this forum.

 

Base on the lisp code you posted, what you require is not even that difficult, help will be given to you as soon as  a not so busy forum member will get to it and will doing it out of the goodness of their hearts. All we're asking is for you to be patient.

 

Post a drawing so we can have a look at it, and avoid a lot of guesswork.

0 Likes
Message 3 of 11

3arizona
Advocate
Advocate

i was able to remove state-2, attribute value. If go this option i  have to create a new block. 

 

Is it possible for lisp to update if visibility change between state-1 and state-2? attached is a copy of my drawing. 

Thank you for your time .

0 Likes
Message 4 of 11

pbejse
Mentor
Mentor

@3arizona wrote:

i was able to remove state-2, attribute value. If go this option i  have to create a new block. 

 

Is it possible for lisp to update if visibility change between state-1 and state-2?


What do you mean by lisp to update?  is it not working the way you wanted it to now? I'm a bit confuse.

You only want to see the value from STATE-2 tag on the Mleader? is that it?

 

On that drawing sample you posted. what is suppossed to nbe the value on the MLEADER?

Where is the block with both STATE-1 and STATE-2. we need that back

 

0 Likes
Message 5 of 11

3arizona
Advocate
Advocate

At the moment lisp shows both states as shown in drawing.  The only difference in the dynamic block drawing is a washer.  I was able to change lisp to read one attribute (state) and i can use it that way but i wanted to know if below was possible. 

 

If possible i want mleader to ONLY show current state,  if i toggle from one state to another.  

0 Likes
Message 6 of 11

pbejse
Mentor
Mentor

@3arizona wrote:

At the moment lisp shows both states as shown in drawing.  The only difference in the dynamic block drawing is a washer.  I was able to change lisp to read one attribute (state) and i can use it that way but i wanted to know if below was possible. 

 

If possible i want mleader to ONLY show current state,  if i toggle from one state to another.  


It sounds easy and I know it is, its just confusing.

confused.gif

I will sleep it off tonight. Start fresh tomorrow 🙂

Short answer is YES, if you put the value of the Visibility State as default on STATE-1 TAG, then the Multileader value will change with the current value of the Visiblity state. We will edit the code tomorrow.

 

 

 

0 Likes
Message 7 of 11

pbejse
Mentor
Mentor

@pbejse wrote:

... if you put the value of the Visibility State as default on STATE-1 TAG, then the Multileader value will change with the current value of the Visiblity state.


TEK WNEO.png

 

I modified your block [ Morpheus.dwg ] to include 2 invisible tags "STATE" and "SIZE"

STATE tag reads the Visibility parameter  "#12 HWH-SD-TEK' as a default value

SIZE tag reads the Linear Parameter "#12 TEK LENGTH " as default value.

 

That is what you will see as the Mleader value STATE | SIZE

 

Also modified the code [ Morpheus.lsp] 

...
(setq at1 (cdr (assoc "STATE" lst)))
(setq at2 (cdr (assoc "SIZE" lst)))
                        )
                    )
 (princ "\nBlock does not contain \"state\" & \"size\" attributes.")
                )
...

 

HTH

 

And to answer your third question..

---Is there too much necessary stuff in lisp for my use. i only use this in Model Space? --

No, not really, the code was written like that for a reason.

 

0 Likes
Message 8 of 11

3arizona
Advocate
Advocate

pbejse,

 

cant test your modified lisp.

Getting error: Pick leader endpoint <exit>: ; error: no function definition: LM:ACDOC. 

 

your updated drawing seem to be updating from state to state, but it's not what i was looking for.  Original lisp reads the attribute Value and that's what i want. The only issue that i have is getting it to read ONLY current Value and update if i switch between both visibility's. sorry, if i'm confusing you. I've attached a ship if it helps.  Maybe it cant be done.

 

thank you and I really appreciate your time

0 Likes
Message 9 of 11

pbejse
Mentor
Mentor

@3arizona wrote:

Getting error: Pick leader endpoint <exit>: ; error: no function definition: LM:ACDOC. 

Duh!  that lisp was posted by you. @3arizona 

 


@3arizona wrote:

your updated drawing seem to be updating from state to state, 

=====================================================================================


@3arizona wrote:

Is it possible for lisp to update if visibility change between state-1 and state-2? attached is a copy of my drawing. 


What does this mean anyway?

 


@3arizona wrote:

.  Original lisp reads the attribute Value and that's what i want. The only issue that i have is getting it to read ONLY current Value and update if i switch between both visibility's


if thats the only thing you want then for STATE-1 refer to attached MLB.lsp  

Command: mlbS1

(vla-put-textstring
  mld
  (strcat
    "%<\\AcObjProp Object(%<\\_ObjId "
    (LM:ObjectID at1)
    ">%).TextString>%"
  )
)

and another one for STATE-2 because..

--- i was able to remove state-2, attribute value. If go this option i  have to create a new block. ---

(vla-put-textstring
  mld
  (strcat
    "%<\\AcObjProp Object(%<\\_ObjId "
    (LM:ObjectID at2)
    ">%).TextString>%"
  )
)

Command: mlbS2

 

Happy now? 🙂

 

And while were at it... 

;; Active Document  -  Lee Mac
;; Returns the VLA Active Document Object

(defun LM:acdoc nil
    (eval (list 'defun 'LM:acdoc 'nil (vla-get-activedocument (vlax-get-acad-object))))
    (LM:acdoc)
)

 

HTH

 

0 Likes
Message 10 of 11

3arizona
Advocate
Advocate

That only breaks it down to two commands for one block.   I will keep searching. 

Again, thank you

0 Likes
Message 11 of 11

pbejse
Mentor
Mentor

@3arizona wrote:

That only breaks it down to two commands for one block.   I will keep searching. 

Again, thank you


 

Yup, might as well because I still dont know what you want..

Whew... glad thats over for me, what a  nightmare. 😁

 

0 Likes