Linking Attribute Tag with Diesel Expression (User to pick value from list)

Linking Attribute Tag with Diesel Expression (User to pick value from list)

traci_haberghamJQEJT
Enthusiast Enthusiast
1,866 Views
19 Replies
Message 1 of 20

Linking Attribute Tag with Diesel Expression (User to pick value from list)

traci_haberghamJQEJT
Enthusiast
Enthusiast

Hi there,

 

I'm wondering if it is possible to add a diesel expression within an attribute tag so the user can select a value from a predefined list?

 

I have an area tag and want the ROOMNAME attribute to open up a list for the user to choose from.

 

Is this possible?  Sample drawing attached with said blocks.

 

Thank you

Traci

0 Likes
Accepted solutions (1)
1,867 Views
19 Replies
Replies (19)
Message 2 of 20

cadffm
Consultant
Consultant

Hi,

 

sorry, you can't do anything like this with DIESEL.

 

If you want to have a drop-down, explore the possibilities of "dynamic blocks"

https://help.autodesk.com/view/ACD/2025/ENU/?guid=GUID-AA47163A-9ECC-49FE-92DB-AB05D2691E1C

YT: https://www.youtube.com/results?search_query=dynamic+blocks

Forum: https://forums.autodesk.com/t5/dynamic-blocks-forum/bd-p/154

 

Sebastian

0 Likes
Message 3 of 20

traci_haberghamJQEJT
Enthusiast
Enthusiast

Thanks, do you think it could be done with a pop list/dcl list and then the value is updated within the attribute?  So maybe the user runs a command instead of double click on an attribute tag to update the value.  There are too many values for a dynamic block, I think that route would take a long time to develop.

 

0 Likes
Message 4 of 20

cadffm
Consultant
Consultant

By programming it is possible, sure.

In this case you have to start this lispfunction to select the attribut.

 

Sebastian

0 Likes
Message 5 of 20

paullimapa
Mentor
Mentor

If the list for Room name selection is always the same then definitely a lisp function to select the matching Block name and then present a dialog with a list for selection which when OK is clicked will replace the Value in the matching Tag.

Do you have a predefined list of Room names you want to include?

In fact now that I'm thinking about it, the lisp function can even read from a text file which can be changed as needed so that the list presented will always be up to date.


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 6 of 20

traci_haberghamJQEJT
Enthusiast
Enthusiast

Hi Paul, yes the list is always the same.  I have a list in a text file.

 

How would I structure the lisp?

 

Invoke command

User select value from list

Update chosen block with chosen data?

 

Thanks

Traci

0 Likes
Message 7 of 20

paullimapa
Mentor
Mentor

Yes it could be in your order or the order I mentioned in my last post. I personally prefer to invoke the lisp command (let’s call it RM with filename rm.lsp), then request user to select block (filtering selection only to block with attributes matching the block name). Only when there is a selection then the list of the room names is presented in a dialog box for user selection. After a room name is selected and the ok button is clicked then the block attribute value is changed to the room name selected. 
If you know lisp and how to code a dcl file that presents the list box on the fly this should be very easy to do. 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 8 of 20

paullimapa
Mentor
Mentor

Attached is my take on RM.lsp which:

1. Requires you to first select the specific Block named "PG_Ann_Area_Roomtag_Pln_Dyn"

2. Reads from the hard drive location for file ROOM.txt to generate the list of Room Names

3. Generates dialog with list box on the fly for selection

4. Changes Attribute Tag name "ROOMNAME" with the selected name

paullimapa_2-1738701801839.png

 

You'll need to change the location where you store your Room.txt file at the beginning of the code here:

 

 (setq 
       txtnam "c:\\autodesk\\Room.txt"          ; room label text file
       blknam "PG_Ann_Area_Roomtag_Pln_Dyn"     ; name of block
       tagnam "ROOMNAME"                        ; name of attribute tag
       RM_olderr  *error*                       ; Save error routine
       *error* RM_err                           ; Substitute ours
       acd_TmpDir (strcat (getenv"Temp")"\\")   ; acad temp folder location
       rm_app "RM"                              ; app name
 )

 

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 9 of 20

traci_haberghamJQEJT
Enthusiast
Enthusiast

Oh wow that's amazing!  Thank you, I'll give this a go today 🙂

 

0 Likes
Message 10 of 20

paullimapa
Mentor
Mentor
Accepted solution

You are welcome…cheers!!!


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 11 of 20

traci_haberghamJQEJT
Enthusiast
Enthusiast

This works amazingly, thank you, you've saved me about a month of my life 😁

0 Likes
Message 12 of 20

paullimapa
Mentor
Mentor

glad to have helped...cheers!!!


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 13 of 20

cadffm
Consultant
Consultant

Hi,

 

It's great that Paul has given you a complete program for non-dynamic blocks.

 

One correction still needs to be made:
1. Correct a typo, which is relevant if the Room.txt cannot be found:
Search for STRCCAT and replace it with STRCAT

 

2. If you want to have the option of (always) selecting multiple blocks,
the code would look like this: see below
However, you will probably mostly prefer the single selection,
because multiple changes are rather rare.

 

 

cadffm_0-1738834560534.png

 

Sebastian

0 Likes
Message 14 of 20

traci_haberghamJQEJT
Enthusiast
Enthusiast

Thanks Sebastian, I'll have a look at that.  I'm already thinking how I could take this to the next level as we do have different types of areas (all using the same block) that are scheduled off in different ways.  The initial step was getting consistent information from the user so when extracted into excel the data can be handled with no typos!

 

0 Likes
Message 15 of 20

paullimapa
Mentor
Mentor

nice catch on the misspelling..I'll revise & update the post with the lisp attachment.


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 16 of 20

paullimapa
Mentor
Mentor

One way would be to introduce to the Block Visibility States making it a dynamic Block to provide a list of the different areas for selection. Then the lisp code would determine what is the current Block's Visibility State and then look for the matching ROOM.txt file.  But you would encounter the problem of whenever you need to modify the list of different areas you would have to edit & modify the Block that's already been inserted in each drawing.

Another way would be to introduce a different Block name (with the same Attribute information) but used for each of the different areas. This could mean you will use another lisp routine to present a list of these different areas (again from reading off of a file like AREAS.txt) each time you want to insert a Room Label Area Block. 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 17 of 20

traci_haberghamJQEJT
Enthusiast
Enthusiast

I did initially try this but struggled to get them to work with the attributes.  The first one invoked a list within the block which the user selected but that didn't update the attribute values and the second a dynamic block with visibility states with all the different values.  They both acted differently and didn't update the attributes properly, it was bizarre so I moved away from the dynamic blocks.

 

The solution you provided is perfect as its easily maintained and I can extract the information easily from the blocks 😀

0 Likes
Message 18 of 20

paullimapa
Mentor
Mentor

I believe the way to get it to work may be to use a constant attribute. With each visibility state (room name) chosen you’ll have a different constant attribute value  which in this case would be the room name label. Constant attribute also prevents users from changing that attribute by mistake and you’re still able to extract that data out. But still a hassle when/if you need to change the room name label list then every dwg with that Block already inserted would have to be updated. Reading from a text file should definitely give you the flexibility of always presenting to the user the latest room name label. But users will have to run this separate lisp function to get it done. Like you though I would also opt to go with a separate lisp function…cheers!!!


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 19 of 20

Village_Idiot
Contributor
Contributor

Dragging up an old thread.

Not to poo poo Paul's idea.  He always has great solutions.

Unless I'm not understanding, this could all be done with a dynamic block using a block properties table.  I have used them to change attributes, visibility state, and move stretch grips all with one selection from a drop down.  

0 Likes
Message 20 of 20

traci_haberghamJQEJT
Enthusiast
Enthusiast

Yes it could be done with a dynamic block but the list evolves and it keeps it simple (two seconds to add another value to the list).  We have dynamic blocks like this but after using the pop list, this is definitely the way forward for us when it comes to populating data within blocks.  I think you use whichever suits what you're trying to achieve.

0 Likes