Attribute value from text .dat

Attribute value from text .dat

Anonymous
Not applicable
3,088 Views
15 Replies
Message 1 of 16

Attribute value from text .dat

Anonymous
Not applicable

Hi,

 

I'm a novice on lisp and especially DCL.

Please help me out in this lisp with DCL to insert an attribute block in my dialog where I can select the Brand & Code values from the drop down popup-list. This is to enhance my attribute entry to every insertion of this block. There are about 150 values for both Brand and Code that I need on every drawing. Attached are the DCL, Lisp, block and the .DAT. I hope the values can be taken from the .DAT.

I had posted this at CADTutor.net but did not get much response. Thanks for the guy help anyway.

 

What I hope to acheive:

  1. insert block with my dcl that I can select the Brand & Code.
  2. values for Code and Brand are from .dat.
  3. if possible, if I select a code, it automatically filled brand base on the .dat and vice versa. I hope I not asking too much here.

Thanks..

 

DCL:

br : dialog { label = "Enhanced Attribute Input"; width = 42;
		: popup_list { label = "Code  "; key = "sel-code"; value = 3; allow_accept = true; }
		: popup_list { label = "Brand"; key = "sel-brand"; value = 3; allow_accept = true; }
		: spacer { width = 1; }
		ok_cancel;
		}

Lisp:

(defun C:BRAND (/ names dcl_id lst cd br it bk pt)
  (setq names '("1000 - COUNTRY ROAD WOMENS" "1011 - SPORTCRAFT"
                "1022 - DAVID LAWRENCE" "2100 - FRAGRANCE TRI"
                "2117 - FRAGRANCE L'OR" "2133 - BURBERRY BEAUTY"
                )
        )
  (if (and (< 0 (setq dcl_id (load_dialog "brand.dcl")))
           (new_dialog "br" dcl_id)
           )
    (progn
      (setq lst (mapcar '(lambda (x) (cons (substr x 1 4) (substr x 8)))
                        names
                        )
            cd  (mapcar 'car lst)
            br  (mapcar 'cdr lst)
            )
      (mapcar '(lambda (k v)
                 (start_list k)
                 (mapcar 'add_list v)
                 (end_list)
                 )
              '("sel-code" "sel-brand")
              (list cd br)
              )
      (action_tile "cancel" "(done_dialog)")
      (action_tile
        "accept"
        "(setq it (mapcar 'atoi (list (get_tile \"sel-code\") (get_tile \"sel-brand\")))) (done_dialog)"
        )
      (start_dialog)
      (unload_dialog dcl_id)
      (if
        (and
          (apply 'and it)
          (setq pt (getpoint "\nPick Attribute insertion point: "))
          (if (not (or (tblsearch "BLOCK" (setq bk "AREA_ATTRIB_M"))
                       (setq bk (findfile "H:/AREA_ATTRIB_M.dwg"))
                       )
                   )
            (progn
              (princ
                "\nBlock not found drawing and either in H:DCL Test folder !"
                )
              nil
              )
            t
            )
          )
         (command "_.-insert"
                  bk
                  "_non"
                  pt
                  "1"
                  "1"
                  "0."
                  (nth (car it) cd)
                  (nth (cadr it) br)
                  ""
                  ""
                  )
         )
      )
    )
  (princ)
  )

Data:

**CODE & BRANDS
**CODE, BRANDS
**----------------
*1006-COUNTRY ROAD WOMENS
1006,COUNTRY ROAD WOMENS
*1014-SPORTCRAFT
1014,SPORTCRAFT
*1022-DAVID LAWRENCE
1022,DAVID LAWRENCE
*2379-OPI
2379,OPI
*2565-MAC
2565,MAC
*3498-BLAZER
3498,BLAZER
*4753-QUICKSILVER
4753,QUICKSILVER
0 Likes
3,089 Views
15 Replies
Replies (15)
Message 2 of 16

_Tharwat
Advisor
Advisor

The guy who helped you out by writing the lisp codes has a name I think.

0 Likes
Message 3 of 16

Anonymous
Not applicable

Hi Tharwat,

 

Sorry I left out your name. Thanks for all your help.

 

It would be much appreciated if you could please continue to help me to fix my Lisp.

 

Thanks again.. 

 

0 Likes
Message 4 of 16

hmsilva
Mentor
Mentor

@Anonymous wrote:

Hi,

 

I'm a novice on lisp and especially DCL.

Please help me out in this lisp with DCL to insert an attribute block in my dialog where I can select the Brand & Code values from the drop down popup-list. This is to enhance my attribute entry to every insertion of this block. There are about 150 values for both Brand and Code that I need on every drawing. Attached are the DCL, Lisp, block and the .DAT. I hope the values can be taken from the .DAT.

I had posted this at CADTutor.net but did not get much response. Thanks for the guy help anyway.

 

What I hope to acheive:

  1. insert block with my dcl that I can select the Brand & Code.
  2. values for Code and Brand are from .dat.
  3. if possible, if I select a code, it automatically filled brand base on the .dat and vice versa. I hope I not asking too much here.

....


@_Tharwat

I hope you do not mind, my friend!

 

@Anonymous,

It is a good principle to link mew messages to the previous ones...

http://www.cadtutor.net/forum/showthread.php?96603-Attribute-dcl-popup-list&highlight=names+dcl_id+l...

 

To me, it does not make sense to have two 'popup_list' one for 'CODES' and another for 'BRANDS', since a CODE will only corresponds one BRAND, and vice versa.
My suggestion is to use only one 'popup_list' and use the 'CODES' and 'BRANDS'...

i.e.
1006,COUNTRY ROAD WOMENS
1014,SPORTCRAFT
1022,DAVID LAWRENCE
2379,OPI
2565,MAC
3498,BLAZER
4753,QUICKSILVER
...

 

Said that, what I 'quick and dirty' did from the code revised by Tharwat, was:

 

Change the DCL file to have just one 'popup_list', the 'BRANDS'
Change the LSP file to read the 'brand.dat' file and create the names list from it
Call the revised DCL to get the 'BRAND'
Insert the 'AREA_ATTRIB_M.dwg' without modifying the attributes strings
Change the attributes strings with the return from DCL


Please keep in mind that those codes attached by me, are just a starting point and untested...

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 5 of 16

Anonymous
Not applicable

Henrique,

 

That was excelent... !  Thanks so much...

Just minor thing which can be ignore. The Cancel still try to insert the block but an Esc easily terminate.

One thing just thought of, if its possible to display the Code in the dialog box. Reason is sometime a Brand can have multiple Codes. I know it sound strange. With the code display one can determine which brand to choose.

 

I like to thank you again for your great effort.

 

Cheers

mcmk8

0 Likes
Message 6 of 16

Anonymous
Not applicable

Almost missed this. Is there a possbility that if I changed a code in data .dat file, it can sync and update the particular code in the drawing.

It's ok if not possible, but it will be very good if possible.

 

Thanks again.

mcmk8

0 Likes
Message 7 of 16

_Tharwat
Advisor
Advisor

@hmsilva wrote:

@_Tharwat

I hope you do not mind, my friend!


Henrique


Hi Henrique,

 

You know I don't mind at all. 

 

Here is the thread for the same OP that I tried to help him but it seems that he is singing in a place far away from my questions so I decided to stay a side Smiley Happy

 

THIS THREAD

Message 8 of 16

hmsilva
Mentor
Mentor

@_Tharwat wrote:

@hmsilva wrote:

@_Tharwat

I hope you do not mind, my friend!


Henrique


Hi Henrique,

 

You know I don't mind at all. 

 

Here is the thread for the same OP that I tried to help him but it seems that he is singing in a place far away from my questions so I decided to stay a side Smiley Happy

 

THIS THREAD


Hi Tharwat,

I understand that.
I did read that thread, I even put a link in my previous message... 🙂

 

Cheers
Henrique

 

EESignature

0 Likes
Message 9 of 16

hmsilva
Mentor
Mentor

@Anonymous wrote:

Henrique,

 

That was excelent... !  Thanks so much...

Just minor thing which can be ignore. The Cancel still try to insert the block but an Esc easily terminate.

One thing just thought of, if its possible to display the Code in the dialog box. Reason is sometime a Brand can have multiple Codes. I know it sound strange. With the code display one can determine which brand to choose.

...


You're welcome, mcmk8,

attached, revised code to call the original 'brand.dcl' file.

 


@Anonymous wrote:

Almost missed this. Is there a possbility that if I changed a code in data .dat file, it can sync and update the particular code in the drawing.

...


 mcmk8,

if to a 'CODE' would correspond only one 'BRAND' it would be easy to read the .dat file, and change the CODE values if they were different in a specific BRAND, but you have said:

'sometime a Brand can have multiple Codes'

so, it should not be possible ...

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 10 of 16

Anonymous
Not applicable

Henrique,

 

Sorry my explaination wasn't too clear.

What I mean earlier was in the .dat, the same brand can have few codes. Eg. Storage have three codes, 1122,1133,1144.

In the dialog box during insertion, I wish to know which Storage I am choosing if I select one before placing, ie. if the code can be visible (but not selectable) in the dialog.

 

.dat

1122,STORAGE

1133,STORAGE

1144,STORAGE

 

Thanks

mcmk8

0 Likes
Message 11 of 16

hmsilva
Mentor
Mentor

@Anonymous wrote:

Henrique,

 

Sorry my explaination wasn't too clear.

What I mean earlier was in the .dat, the same brand can have few codes. Eg. Storage have three codes, 1122,1133,1144.

In the dialog box during insertion, I wish to know which Storage I am choosing if I select one before placing, ie. if the code can be visible (but not selectable) in the dialog.

 

.dat

1122,STORAGE

1133,STORAGE

1144,STORAGE

 

Thanks

mcmk8


Hi mcmk8,

I'm with a very large workload, if I have some free time, I'll see what I can do...

 

Henrique

EESignature

0 Likes
Message 12 of 16

hmsilva
Mentor
Mentor

Revised code...

It will load 'brand_h.dcl'.

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 13 of 16

Anonymous
Not applicable

I am coming back to this to see if the selection from the drop down list can be improve by adding a new Group in the .dat

 

The new brand.dat would be as below, Group,Code,Brand:

brand.dat

Womens,1242,Virgo

Womens,1268,Sara

......

Kids,4711,Hux Baby

Kids,4606,Gant

......

 

With the introduction of Group, we hope this will be a filter to the Brand list. Since the brand.dat numbers are growing from 150 to 200, we hope the dropdown list will be shorten with the new Group field.

 

Attached is a small version of my .dat for testing. I hope the new dialog I can choose Group then Brand (Group filtered) before inserting the attribute block.

 

Thanks

mcmk8

 

0 Likes
Message 14 of 16

FrisoKramer
Enthusiast
Enthusiast
Hi _Tharwat, Thank you for posting the code. We had been trying for a day or so to write a similar routine / dialog box that utilised ini files for layers, block names and popup list values for attributes. We had been kind of struggling until one of my colleagues found this thread where your code is really nicely structured and simple to follow. By using some of this code and a few of Lee Mac's routines we have managed to create what we were trying to achieve. To give credit where credit is due I would like to acknowledge you in our lisp file and documentation. Would that be ok? If you have any preference for the wording please feel free to send me a PM Cheers Paul
0 Likes
Message 15 of 16

_Tharwat
Advisor
Advisor

@FrisoKramer wrote:
Hi _Tharwat, Thank you for posting the code. We had been trying for a day or so to write a similar routine / dialog box that utilised ini files for layers, block names and popup list values for attributes. We had been kind of struggling until one of my colleagues found this thread where your code is really nicely structured and simple to follow. By using some of this code and a few of Lee Mac's routines we have managed to create what we were trying to achieve. To give credit where credit is due I would like to acknowledge you in our lisp file and documentation. Would that be ok? If you have any preference for the wording please feel free to send me a PM Cheers Paul

Many thanks for your kind words Paul, highly appreciated.

 

I don't have any reference but I would love to be of any assistance if you are in need of any help in this regard.

I would love to know what you have so far with that lisp file and documentation if that possible so you can PM me if that is okay with you.

 

Best regards

 

Tharwat

0 Likes
Message 16 of 16

FrisoKramer
Enthusiast
Enthusiast
Thank You, that sounds great. I'll send you a PM shortly. We are implementing a CAD standard for work as executed drawings that is compatible with Open Spatial's system for validating drawings, and planning to have the new files and menus ready by the end of next week. We needed to make it easier for the consultants to use since there are some 150 standard blocks that need to go on the right layers and very specific attribute data. The end result is coming along pretty awesome. What makes it so unusual is that after getting the first routine and dialog box to work. I got one of my staff to write SQL to generate three main ini files, 150 lisp routines and 150 DCL files in a matter of seconds from our oracle database. We did it this way to make it easier to have it all in sync and maintain as well as use for other standards. We have also added smarts into the menus / routines to manage the layers incredibly well. We are also partly through generating help files the same way. Those also have "dialog boxes" (forms) in them with popup lists and copy buttons so LT users can use the help files to get the correct attributes.. I am sure that after it gets implemented the consultants will ask for more functionality once they see how much time it is saving them. The ini files work well for configuring layers, block names, attributes and pick lists. Lee Mac's routines mean the lisp files do not need to constantly open and read the data because it can be stored in lists. I certainly cannot wait to get it finished.
0 Likes