Author Topic: ATTEDIT my way?  (Read 10583 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
ATTEDIT my way?
« on: September 10, 2005, 11:26:31 AM »
I was looking for a routine that uses a dialog box to edit the attributes of a block
just like ATTEDIT does. The reason I was looking was that I wanted to control which
attributes were displayed & edited.   

i know you could temporarily set the value of the attribute to 'Constant' and send the
block to Command 'ATTEDIT' but if you are going to do that why not just use your own
dialog box?

Anyone have a routine like that or have another idea to limit user access to a given
attribute while using the ATTEDIT dialog box?
I've reached the age where the happy hour is a nap. (°Ώ°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: ATTEDIT my way?
« Reply #1 on: September 10, 2005, 11:44:00 AM »
<RambleOn>

What I've done in the past for some custom blocks I defined (via code) is to define the geometry only in the block definition. All attributes are created on the fly. Since AutoCAD (attedit) looks to the block definition when populating the attedit dialog it comes up empty, which is exactly what I want: I want the attributes to display on the drawing but want them to be read-only, but not constant per se, as they need to have different values per block instance. Side note: if you make attributes on the fly you can make them constant, yet the values can differ instance to instance. Anyway, I've not created a dialog for this, as the data I push to the attributes comes from a database, but it's a good idea Alan. You could track changes (without need for a reactor), pushing historical data (call 'em attribute revisions if you will) to a LIFO dictionary etc.

</RambleOn>
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com • http://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: ATTEDIT my way?
« Reply #2 on: September 10, 2005, 11:57:04 AM »
I am not sure what you are looking for exactly .. maybe I am just not understanding your needs ... anyway check out this program it is an attribute editor that allows you to change the flags of the attributes along with a whole lot of other things.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: ATTEDIT my way?
« Reply #3 on: September 10, 2005, 12:18:28 PM »
Very interesting, as always...

I now remember you touching on this in previous threads. If I understand you correctly,
The attributes are added via a entmake for the INSERT and the locks out the casual user.
If they INSERT a new copy of that block it is without attributes.
The inserts with attributes are only accessible vis lisp.
This is very interesting stuff.. Thanks

Michael,
My original thought (original to me :-)) was to have a subroutine that you could send a list
of tag names along with the block ename and the routine would display a dialog box much
like the ATTEDIT dialog box. This would limit the access to attributes that you don't want
have the user change or attributes you are changing via your calling lisp routine.

This would be a universal routine & would work with your stealth attributes. On second thought
your stealth attributes would have no "Prompt" because it is stored in the block definition.
I think the "default Value" may be stored there as well.

Thanks Keith, I'll take a look....
I did not have an immediate need but was thinking about a universal subroutine.
Like i have nothing better to do! :roll:
I've reached the age where the happy hour is a nap. (°Ώ°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: ATTEDIT my way?
« Reply #4 on: September 10, 2005, 12:48:02 PM »
If I understand you correctly, the attributes are added via a entmake for the INSERT and the locks out the casual user. If they INSERT a new copy of that block it is without attributes. The inserts with attributes are only accessible vis lisp (mp: or vb, arx ...).

You got it right.

Quote from: CAB
My original thought (original to me :-)) was to have a subroutine that you could send a list of tag names along with the block ename and the routine would display a dialog box much like the ATTEDIT dialog box. This would limit the access to attributes that you don't want have the user change or attributes you are changing via your calling lisp routine.

Sounds useful. The only thing is if user x calls attedit your security, if we want to call it that, is bypassed. Still, if you had a block with umpteen attributes, yet only 3 were applicable for a particlular use your CABATTEDIT would be perfect.

Quote from: CAB
This would be a universal routine & would work with your stealth attributes. On second thought your stealth attributes would have no "Prompt" because it is stored in the block definition. I think the "default Value" may be stored there as well.

All you'd have to do is walk the attributes following the insert and then construct a dcl on the fly to reflect the attributes you wanted to expose. Very do-able.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com • http://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: ATTEDIT my way?
« Reply #5 on: September 10, 2005, 02:13:07 PM »
The only thing is if user x calls attedit your security, if we want to call it that, is bypassed. Still, if you had a block with umpteen attributes, yet only 3 were applicable for a particlular use your CABATTEDIT would be perfect

Well my reasons were not for security but convenience & to avoid having a clumsy user
from entering data that should not be changed.
Using the title block as an example, the 'Drawing Title'  'Author' & 'Subject' should be
changed in Drawing Properties & updated via the lisp. These would not be offered in the
CABATTEDIT dialog box but would exist in the block as attributes. Just an example.
I've reached the age where the happy hour is a nap. (°Ώ°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: ATTEDIT my way?
« Reply #6 on: September 10, 2005, 02:18:49 PM »
'Kay, ya got me curious Alan, I agree on the convenience issue (I acknowledged that in my last post) but how does "security" differ from "avoid having a user modify data that should not be changed"?

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com • http://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: ATTEDIT my way?
« Reply #7 on: September 10, 2005, 02:43:48 PM »
Quote
security
 noun
 1  security, security_measures
 
   measures taken as a precaution against theft or espionage or sabotage etc.;
    "military security has been stepped up since the recent uprising" 


I suppose it's the same thing. In my case it's security against accidental alteration
of an attribute. BUT, I had no intentions of preventing the user from using the ATTEDIT
command and changing the value. I was a case of the value does not need to be changed
in the situation, so don't give the user the opportunity to screw up. :-)

Back to the Open.
I've reached the age where the happy hour is a nap. (°Ώ°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: ATTEDIT my way?
« Reply #8 on: September 10, 2005, 02:50:13 PM »
I was thinking more like "secure data from unauthorized viewing, modification or deletion; combinations thereof", like drawing title, author, revision number etc.

6 of one, half a dozen of the other.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com • http://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: ATTEDIT my way?
« Reply #9 on: September 10, 2005, 03:47:04 PM »
Yes, my use of 'secure' was too narrow.
The edit routine would deal with secure & unsecure INSERTs & the security
would be up to the block creators. In the secure Insert scenario the calling
routine would have to supply the Prompts as there would be none to retrieve.
I've reached the age where the happy hour is a nap. (°Ώ°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: ATTEDIT my way?
« Reply #10 on: September 10, 2005, 04:30:35 PM »
Uncle.

:-D
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com • http://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: ATTEDIT my way?
« Reply #11 on: September 10, 2005, 08:06:06 PM »
Sorry Michael, was not my intent..
I've reached the age where the happy hour is a nap. (°Ώ°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: ATTEDIT my way?
« Reply #12 on: September 10, 2005, 10:16:12 PM »
There's no need to apologize Alan.

8-)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com • http://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: ATTEDIT my way?
« Reply #13 on: September 12, 2005, 04:53:20 PM »
After some homework here is version 1.00

It does not support the stealth attributes yet. :-)

It does support paging & selective attribute editing.
;;;  Note, that the Tag Names must be in Upper case & no spaces allowed.
;;;  If you pass nil then all non-constant tag will be edited
;;;  Flag if true, only tags in the list will be edited
;;;  Flag if nil,  Tags in the list will be excluded

No error checking for incorrect tag names.

;;; ARGUMENTS
;;; ename   entity name of the block to edit
;;; taglst  list of tag names to edit, nil = edit all
;;; editflg T edit names in list, nil = exclude names in list

 [    OK    ] Update the block
 [  Cancel  ] Quit without changes
 [   Next   ] Display the next page
 [   Prev   ] Display the previous page
 [   Help   ] Display help
While in a field the ENTER key will send you
to the next field.
I've reached the age where the happy hour is a nap. (°Ώ°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: ATTEDIT my way?
« Reply #14 on: September 12, 2005, 05:15:22 PM »
Lookin' good Mr. Butler, as usual.

Suggestion: Add a state field to indicate whether a particular attribute value has been modified from the original, for example, a red asterisk:

Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com • http://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: ATTEDIT my way?
« Reply #15 on: September 12, 2005, 06:03:41 PM »
Oooh I like the way you think.. :-D
I've reached the age where the happy hour is a nap. (°Ώ°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: ATTEDIT my way?
« Reply #16 on: September 12, 2005, 06:06:52 PM »
Oooh I like the way you think.. :-D

Then it's mutual.

:-D
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com • http://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: ATTEDIT my way?
« Reply #17 on: September 12, 2005, 08:31:43 PM »
Here is version 1.02
But for the life of me I can't remember how to get rid of the frames around the vector images.
I have done it before but can't seem to get these to go away.
I've reached the age where the happy hour is a nap. (°Ώ°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: ATTEDIT my way?
« Reply #18 on: September 12, 2005, 10:16:13 PM »
Maybe a text tile set to "*" or "" as appropriate instead of an image tile?
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com • http://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: ATTEDIT my way?
« Reply #19 on: September 12, 2005, 10:27:41 PM »
Got it. :-D
Now for the alignment. 8-)

PS Got that too.
« Last Edit: September 12, 2005, 11:02:18 PM by CAB »
I've reached the age where the happy hour is a nap. (°Ώ°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: ATTEDIT my way?
« Reply #20 on: September 12, 2005, 11:08:11 PM »
I've frequently heard how difficult or laborious dcl programming is and I just don't see it. While a dcl based dialog can't challenge one defined by a more modern application like Delphi or Visual BASIC, they're a snap to make (and since they're plain text, can be written on the fly, though that's another discussion), particularly if you build sub assemblies to use in your dialog. Once you define sub assemblies the only thing, generally speaking, that varies from instance to instance is the key (and sometimes the label).

For example, in the dcl CAB authored it could be broken down like this (this would all be in one file, but breaking it up like this for discussion makes it easier to digest):

General dcl settings

Code: [Select]
//
//  general dcl settings
//

dcl_settings : default_dcl_settings

{ audit_level = 3; }

Sub assembly definitions:

Code: [Select]
//
//  sub assembly definitions
//

attribute_prompt : text {
    value = "Attribute Prompt" ;
    width = 30;
    fixed_width = true;
}

attribute_value : edit_box {
    edit_width = 34;
    edit_limit = 200;
    fixed_width = true;
}

attribute_state : image_button {
    height = 1;
    width  = 2;
    fixed_width = true;
    fixed_height = true;
    aspect_ratio = 1;
    color  = -15;
}

mybutton : button {
    width = 12;
    fixed_width = true;
}

Dialog definition:

Code: [Select]
//
//  dialog definition
//

MyAttEdit : dialog {
 
    label = "   MyAttEdit by CAB v1.0";
   
    :   text {
        value = "Block Name:  My Block";
        key   =  "txtblock";
        width = 50;
    }

    :   text {
        value = "Page # ";
        key   =  "page";
        width = 10;
        alignment = right;
    }
   
    spacer_1;
   
    //  use the sub assemblies we defined
     
    :   row {
        :   attribute_prompt { key = "txt1"; }             
        :   attribute_value  { key =  "eb1"; }             
        :   attribute_state  { key =  "im1"; }   
    }
   
    :   row {
        :   attribute_prompt { key = "txt2"; }             
        :   attribute_value  { key =  "eb2"; }             
        :   attribute_state  { key =  "im2"; }   
    }
   
    :   row {
        :   attribute_prompt { key = "txt3"; }             
        :   attribute_value  { key =  "eb3"; }             
        :   attribute_state  { key =  "im3"; }   
    }
   
    :   row {
        :   attribute_prompt { key = "txt4"; }             
        :   attribute_value  { key =  "eb4"; }             
        :   attribute_state  { key =  "im4"; }   
    }
   
    :   row {
        :   attribute_prompt { key = "txt5"; }             
        :   attribute_value  { key =  "eb5"; }             
        :   attribute_state  { key =  "im5"; }   
    }
   
    :   row {
        :   attribute_prompt { key = "txt6"; }             
        :   attribute_value  { key =  "eb6"; }             
        :   attribute_state  { key =  "im6"; }   
    }
   
    :   row {
        :   attribute_prompt { key = "txt7"; }             
        :   attribute_value  { key =  "eb7"; }             
        :   attribute_state  { key =  "im7"; }   
    }
   
    :   row {
        :   attribute_prompt { key = "txt8"; }             
        :   attribute_value  { key =  "eb8"; }             
        :   attribute_state  { key =  "im8"; }   
    }
   
    spacer_1;

    :   row {
        :   mybutton  { key = "ok";     label = "&OK";                         }
        :   mybutton  { key = "cancel"; label = "&Cancel";   is_cancel = true; }
        :   mybutton  { key = "prev";   label = "&Previous";                   }
        :   mybutton  { key = "next";   label = "&Next";                       }
        :   mybutton  { key = "help";   label = "&Help";                       }
    }

}

This greatly speeds up dcl development, moreover, it makes maintenance a snap. Did ya note how I right aligned the key values for all the instanced sub assemblies? Makes it easy to assign and ensure the keys are correct (typically numerically incremented).

But more on maintenance ...

For example, if the attribute_prompt sub assembly width is found to be too wide, the width = 30; statement could be changed to width = 25; and all 8 instances will reflect same. Really takes the chore out of maintenance and makes it a lot easier to achieve consistancy throughout a dialog.

Another example: Say we decide to change the attribute_state sub assembly to a text tile from an image_button. No Problem:

Code: [Select]
/*attribute_state : image_button {
    height = 1;
    width  = 2;
    fixed_width = true;
    fixed_height = true;
    aspect_ratio = 1;
    color  = -15;
}*/

attribute_state : text {
    fixed_width = true;
    width = 1;
    is_bold = true;
}

Now all 8 instances of attribute_state are text tiles instead of image buttons (ps: I think if you made the image buttons just image tiles there may not be a border around them Alan).

Of course the code would have to reflect same:

Code: [Select]
(defun asterisk ( tile / x y )

    (set_tile tile "*")
   
    ;| <comment out former code>
   
    (setq
        X (dimx_tile tile)
        Y (dimy_tile tile)
    )
    (start_image tile)
    (fill_image 0 0 x y -15)
    (mapcar 'vector_image; Color 1
        (list  5 1 1  0)
        (list  0 9 1  5)
        (list  5 9 9 10)
        (list 10 1 9  5)
        (list  1 1 1  1)
    )
    (end_image)

    </comment out former code> |;
)

And:

Code: [Select]
(defun ast_clear ( tile / x y )

     (set_tile tile "")
     
    ;| <comment out former code>

    (setq
        X (dimx_tile tile)
        Y (dimy_tile tile)
    )
    (start_image tile)
    (fill_image 0 0 x y -15)
    (end_image)

    </comment out former code> |;
)

Final tip: Read up on @include statement (in the context of dcl source files and subassembly discussion above).

:-D
« Last Edit: September 12, 2005, 11:38:19 PM by MP »
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com • http://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: ATTEDIT my way?
« Reply #21 on: September 12, 2005, 11:45:37 PM »
Great examples Michael.

So the Sub assemblies act like sub routines, that does help because many of the dialogs
I have created in the past have repetitive fields. I did figure out the image frame issue.

I agree, the DCL dialog is not that tough to create & sure makes for a more interesting interface
than the command line.

OK the @include gives you more power to call on sub assemblies.

I believe it's time for me to order the Developer's Guide. :-)
I'm tired of sifting through the on-line help.
I've reached the age where the happy hour is a nap. (°Ώ°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: ATTEDIT my way?
« Reply #22 on: September 13, 2005, 12:49:28 PM »
Here is the revised code using Micheal's fine example of DCL code.
I've reached the age where the happy hour is a nap. (°Ώ°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.