Need A Lisp That Will Update 2 Visibility States In Dynamic Block Based On 2 Attribute Values

Need A Lisp That Will Update 2 Visibility States In Dynamic Block Based On 2 Attribute Values

reginald-grimes
Contributor Contributor
2,981 Views
12 Replies
Message 1 of 13

Need A Lisp That Will Update 2 Visibility States In Dynamic Block Based On 2 Attribute Values

reginald-grimes
Contributor
Contributor

Good day all.  I'm in need of a lisp routine that will update 2 visibility states simultaneously in my dynamic block based upon the attribute values in the "profile_id_left" and "profile_id_right" .  I greatly appreciate anyone's help with this dilemma.  

 

I've attached a copy of my block to this post.  Fyi, I used the "visibility-add-eng_1_6.lsp" to create the 2 visibility states. Thanks again in advance!

0 Likes
Accepted solutions (1)
2,982 Views
12 Replies
Replies (12)
Message 2 of 13

reginald-grimes
Contributor
Contributor

My apologies, I forgot to provide the values for each visibility state....see attached spreadsheet.

0 Likes
Message 3 of 13

pbejse
Mentor
Mentor

@reginald-grimes wrote:

.. I'm in need of a lisp routine that will update 2 visibility states simultaneously in my dynamic block based upon the attribute values in the "profile_id_left" and "profile_id_right" . ..

 

I've attached a copy of my block to this post.  Fyi, I used the "visibility-add-eng_1_6.lsp" to create the 2 visibility states. Thanks again in advance!


I simply dont get it,  can you please explain more @reginald-grimes 

And where is that lsp?

 

0 Likes
Message 4 of 13

reginald-grimes
Contributor
Contributor

My apologies for not providing enough info and clarity.  I should have used 2 visibility "parameters" instead of 2 visibility "states" in my initial post.  So, "profile_id_left" attribute value is assigned to "profile_id_left" visibility parameter/states, and "profile_id_right" attribute value is assigned to "profile_id_right" visibility parameter/states.  A block table drives the 2 visibility parameters/states and 2 attribute values I just called out.

 

I'm in need of a lsp command that will update "profile_id_left" & "profile_id_right" visibility parameters based on "profile_id_left" / "profile_id_right" attribute values that I manually enter in (or import via csv).  The values will be between 1 & 12 for each visibility parameter.  And blank field values will constitute "NO DUAL PROFILE" visibility state for the profile_id_left visibility parameter; and "NO RIGHT PROFILE" visibility state for the profile_id_right visibility parameter.

 

I simply referred to the "visibility-add-eng_1_6.lsp" lisp so the programmer would know how I created 2 block visibility parameters since that's not native to AutoCAD.  There's no additional programming needed for this specific lisp.  Nevertheless, I've attached the lisp for evaluation purposes, the lisp website link & lisp commands.  http://poleshchuk.spb.ru//cad/2009/tainypod12e.htm

 

I hope this thread brings more clarity to what I'm requesting.  Thank you.

0 Likes
Message 5 of 13

Sea-Haven
Mentor
Mentor

You talk about visibility state of dynamic block, have you looked at Lee-mac dynamic block properties  ?

 

: (LM:getvisibilityparametername obj)
"PROFILE_ID_LEFT"

 

(LM:SetVisibilityState  obj  val)  not sure what val should be.

 

0 Likes
Message 6 of 13

reginald-grimes
Contributor
Contributor

I have seen that, but unfortunately I don't know anything about lisp coding.

0 Likes
Message 7 of 13

pbejse
Mentor
Mentor

@reginald-grimes wrote:

I'm in need of a lsp command that will update "profile_id_left" & "profile_id_right" visibility parameters based on "profile_id_left" / "profile_id_right" attribute values that I manually enter in (or import via csv).  The values will be between 1 & 12 for each visibility parameter.  And blank field values will constitute "NO DUAL PROFILE" visibility state for the profile_id_left visibility parameter; and "NO RIGHT PROFILE" visibility state for the profile_id_right visibility parameter.

 

Thank you for that, but forgive me, I stiil dont get it. 

 

Let say LOCATION_ID value  AB202P 

Visibility:

("PROFILE_ID_LEFT" "8")("PROFILE_ID_RIGHT" "10)

 

AB202P.png

Atribute values:

("PROFILE_ID_LEFT" "8")("PROFILE_ID_RIGHT" "10")

 

Now the CSV data

Column 1
("profile_id_left" "NO DUAL PROFILE" "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12")
Column 2
("profile_id_right" "NO RIGHT PROFILE" "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12")

 

What do you do with these data? how does that relate to the Visibility and Attributes ? 

 

PROFILE_ID_RIGHT doesnt even have the value of 1

 

Value one.png

 

0 Likes
Message 8 of 13

reginald-grimes
Contributor
Contributor

So the goal is, if I decide to import the "profile_id_left" / "profile_id_right" values from the csv, it would then match the visibility parameters/states that have the equivalent name/number.  Which I would like the lisp programming to recognize these attribute values and match the corresponding visibility parameter/state name.  See below:

 

  • attribute value "profile_id_left" = visibility parameter/state "profile_id_left" name
  • attribute value "profile_id_right" = visibility parameter/state "profile_id_right" name

I would like for the csv to export all block attribute fields with headers.  I would also like the csv to contain the block handle.

 

By the way, the value of 1 missing from "PROFILE_ID_RIGHT" selection menu is just an oversight on my part.  I can add that later.  Thank you kindly for your assistance and I hope I've not confused you with the additional information I've provided in this post.

0 Likes
Message 9 of 13

pbejse
Mentor
Mentor

@reginald-grimes wrote:

So the goal is, if I decide to import the "profile_id_left" / "profile_id_right" values from the csv, it would then match the visibility parameters/states that have the equivalent name/number. ...


Believe me, we understand the all that, except the relation of the imported data to the existing blocks is where the confusion is.

 

Block with LOCATION ID AB202P

Current visibility value of "profile_id_left" is 8 and "profile_id_right" is 10.

 

Block with LOCATION ID AB205P

Current visibility value of "profile_id_left" is 6 and "profile_id_right" is 2.

 

If the user run the program, select a block

Change the value only of the current visibility value. in this example change value of 8 to 8 as that is what is specified on the CSV file?

 

or

 

Change all "profile_id_left" and "profile_id_right" values [Visibility and Attribute value] and leave the current as it is? meaning the current visibilty has nothing to do with it?

 


@reginald-grimes wrote:

I would like for the csv to export all block attribute fields with headers.  I would also like the csv to contain the block handle.


And that is another task?  Will that be the same data that will be use for import and the one you attached is not the final format?

 

0 Likes
Message 10 of 13

reginald-grimes
Contributor
Contributor

Let's disregard the csv import/export data piece.  I'll do my best to communicate the answer to your questions - if I'm understanding them correctly.

 

So say the profile_id_left attribute of a block is changed from 7 to and the profile_id_right attribute of that same block is changed from 5 to 9, then the user should be able to run the lisp command which will auto-update the profile_id_left/right visibility states to be 8 & 9.  Which is based on the left/right attribute values.  Maybe 2 external csv's w/ attribute and visibility state equivalents could help drive this function and written into the code.  Don't know, not a programmer - but just an idea.  I was thinking thinking the external csv's would be useful in case I needed to add additional profiles to the block in the future.  I've attached the csv files just in case it can be useful.

 

It would also be great if the lisp could automatically read  (w/o selection) the profile_id_left/right attribute fields of all blocks specifically named "UBER-CLEAN" that's contained within the entire dwg file.  That way possible updates made by a previous user that was potentially missed can be updated.

0 Likes
Message 11 of 13

pbejse
Mentor
Mentor
Accepted solution

@reginald-grimes wrote:

.. So say the profile_id_left attribute of a block is changed from 7 to and the profile_id_right attribute of that same block is changed from 5 to 9, then the user should be able to run the lisp command which will auto-update the profile_id_left/right visibility states to be 8 & 9.  Which is based on the left/right attribute values. 

 

 Lets start with that.

(defun c:uberClean ( / _id_left _id_right ssel) 
      (if (and
                (setq _id_left (getstring "\nEnter value \"profile_id_left\": "))
                (setq _id_right (getstring "\nEnter value \"profile_id_right\": "))
                (setq ssel (ssget "_:L" '((0 . "INSERT")(66 . 1))))
                )
         (UltimateLisp  (list _id_left  _id_right) ssel)
          )
      )
;;	This is the eventual code to be use in conjuncion with CSV. 	;;
(Defun UltimateLisp (ls ss / ss csv ev dp atbV i val vis )   
   (repeat (setq i (sslength ss))
             (setq ev (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
	(if (and
              (eq (vla-get-EffectiveName ev) "UBER-CLEAN")
              (vlax-method-applicable-p ev 'GetDynamicBlockProperties)
              (setq dp (mapcar '(lambda (dp)
                                      (list (Vla-get-PropertyName dp)(Vlax-get dp 'AllowedValues) dp ))
                         (vlax-invoke ev 'GetDynamicBlockProperties))
                    )
              (setq atbV (mapcar '(lambda (at)
                                      (list (Vla-get-TagString at)(Vla-get-TextString at) at ))
                         (vlax-invoke ev 'GetAttributes)))
              )
             (foreach itm (mapcar 'list '("PROFILE_ID_LEFT" "PROFILE_ID_RIGHT") ls)
                  (if
                      (and
                             (setq val (assoc (Car itm) atbV))
                             (Setq vis (assoc (Car itm) dp))
                             (member (cadr itm) (cadr vis))
                             	)
			(progn                      
				(vla-put-textstring (caddr val)(cadr itm))
                         	(vla-put-value (caddr vis)(cadr itm))
                         	)
                        )
                   )
            	)
            )
      (princ)
      )

Command: UBERCLEAN

Enter value "profile_id_left": 6

Enter value "profile_id_right": 8

Select objects: Specify opposite corner: 5 found

Select objects:

 

0 Likes
Message 12 of 13

Sea-Haven
Mentor
Mentor

Makes very little sense to me, ok some background another task with dynamic blocks. A x and y size is found by clicking inside a rectang area, a excel is opened, the X & Y values are placed via a putcell "for us programmers", the excel then updates, the user clicks ok as a formula is checked that meets certain standards, the dynamic block is inserted and adjusted to suit. In particular visibilty states.

 

If I understand correct, So like pbe who has done another excel linked program it should read the handle from the excel as well as the left and right variables, find the block and update the dynamic block. Repeat for all blocks in excel. The inverse is read the blocks and update the excel. 

 

In this gif at end dynamic block window is inserted with chosen visibilty, the screen capture did not show the excel as that is company copyrighted.

 

The excel's provide don't have handles so again not sure how useful. More like this.

hand1,1,2

hand2,2,2

hand3,1,4 and so on.

 

0 Likes
Message 13 of 13

reginald-grimes
Contributor
Contributor

Yes, what you've written works so far.  Awesome!  I think we're progressing on the right track.  I'm ready for the next step whenever you are. 😊

0 Likes