Author Topic: attribute edit  (Read 7149 times)

0 Members and 1 Guest are viewing this topic.

deerailed77

  • Guest
attribute edit
« on: April 14, 2016, 05:57:48 PM »
I am looking for a lisp routine that will work with a attribute block that has tag names the same but the prompts are different.

example the first 12 are all tags and prompts different but then at 13 they start repeating every 6 I know there is a way its long but can be done.  used to have one that I could have used but no longer at that company where I had it.  Plus it was about 10 years ago,  currently using 2015 electrical.

the block name is val_snc_bdr  due to corporate reasons I am unable to post the actual file.  gotta love corporate america.  LOL

example
tag           prompt
REV            rev1
DATE         date1
DESC        desc1
CAD          cad1
CHKD        chkd1
APP           app2
REV            rev2
DATE         date2
DESC        desc2
CAD          cad2
CHKD        chkd2
APP           app2

ChrisCarlson

  • Guest
Re: attribute edit
« Reply #1 on: April 15, 2016, 08:12:27 AM »
Literally have no idea what you are asking

deerailed77

  • Guest
Re: attribute edit
« Reply #2 on: April 15, 2016, 09:47:20 AM »
I have an attributed block that was created that uses the same tag name for multiple attributes.  I need to be able to select say the second one and input the revision number, date, description, cad, chkd, and approved via a lisp.

and then i can edit that one to work for the 3rd row, 4th and so on as needed.

If the idiots that created this block wouldnt have just copied the text and actually gave it a individual value I would be ok. 

deerailed77

  • Guest
Re: attribute edit
« Reply #3 on: April 15, 2016, 09:53:10 AM »
heres an example of the attribute

ronjonp

  • Needs a day job
  • Posts: 7527
Re: attribute edit
« Reply #4 on: April 15, 2016, 09:57:04 AM »
Maybe you could sort them by insertion point & Y values.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: attribute edit
« Reply #5 on: April 15, 2016, 11:21:11 AM »
I would suggest iterating over the block definition and pairing the attribute tags with their respective prompts, and then using such prompts to obtain the appropriate attribute reference to modify.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: attribute edit
« Reply #6 on: April 15, 2016, 12:30:25 PM »
Code: [Select]
(defun c:MyEd ( / _SortAttribsByXY _IsAttributedBlock _Main )

    ;;  Written very quick & dirty for the swamp. Has bugs and
    ;;  communicable diseases, use at your own risk.
    ;;
    ;;  Relies on DOSLIB (http://wiki.mcneel.com/doslib/home)

    (defun _SortAttribsByXY ( attribs / fuzz lst a y groups )

        ;;  First get the fuzz factor, let's make it a function
        ;;  of the height of the first attrib.

        (setq fuzz (* 0.75 (vla-get-height (car attribs))))

        ;;  Since we'll be querying the coordinate data a couple
        ;;  times it makes sence to cache it.

        (setq lst
            (mapcar
                (function
                    (lambda ( a / p )
                        (list
                            (car (setq p (vlax-get a 'InsertionPoint)))
                            (cadr p)
                            a
                        )
                    )
                )
                attribs
            )
        )

        ;;  Initialize the grouping using the first attribute.

        (setq groups (list (vl-list* (cadr (setq a (car lst))) a nil)))

        ;;  Ok. First group the attribs by their y ord.

        (foreach a (cdr lst)
            (setq y (cadr a))
            (if
                (null
                    (vl-some
                        (function
                            (lambda ( g / y! )
                                (if (equal y (setq y! (car g)) fuzz)
                                    (setq groups
                                        (subst
                                            (vl-list* y! a (cdr g))
                                            g
                                            groups
                                        )
                                    )
                                )
                            )
                        )
                        groups
                    )
                )
                (setq groups (cons (vl-list* y a nil) groups))
            )
        )

        ;;  Sort the groups by the y ord, large to small.

        (setq groups
            (vl-sort
                groups
                (function (lambda ( a b ) (> (car a) (car b))))
            )
        )

        ;;  Now sort each group by its members x ord, small to large.

        (setq groups
            (mapcar
                (function
                    (lambda ( g )
                        (vl-sort g (function (lambda ( a b ) (< (car a) (car b)))))
                    )
                )
                (mapcar 'cdr groups)
            )
        )

        ;;  Ok, dispence with the grouping and lose the ordinate
        ;;  info, return to caller.

        (mapcar 'last (apply 'append groups))

    )
   
    (defun _IsAttributedBlock ( object )   
        (cond
            (   (null (eq "AcDbBlockReference" (vla-get-objectname object)))
                (princ "\nNot a block insert.")
                nil
            )
            (   (null (eq :vlax-true (vla-get-hasattributes object)))
                (princ "\nBlock has no attributes.")
                nil
            )
            (t)
        )     
    )

    (defun _Main ( / doc ename object attribs name result new )

        (cond
            (   (progn
                    (vl-load-com)
                    (setq doc (vla-get-activedocument (vlax-get-acad-object)))
                    nil
                )
            )
            (   (null dos_proplist)
                (princ
                    (strcat
                        "\nDo yourself a solid. Download & install DOSLIB."
                        "\tAvailable at http://wiki.mcneel.com/doslib/home."
                    )
                )
            )
            (   (while (setq ename (car (entsel)))
                    (if
                        (and
                            (_IsAttributedBlock (setq object (vlax-ename->vla-object ename)))
                            (setq
                                attribs (vlax-invoke object 'GetAttributes)
                                name    (vla-get-name object)
                            )
                            (setq attribs
                                (mapcar
                                    (function
                                        (lambda ( a )
                                            (list
                                                (vla-get-tagstring a)
                                                (vla-get-textstring a)
                                                a
                                            )
                                        )
                                    )
                                    (_SortAttribsByXY attribs)
                                )
                            )
                            (setq result
                                (dos_proplist "MyEd" (strcat name ":")
                                    (mapcar
                                        (function (lambda ( a ) (cons (car a) (cadr a))))
                                        attribs
                                    )
                                )
                            )
                        )
                        (foreach lst (mapcar 'list result attribs)
                            (if
                                (/=
                                    (setq new (cdar lst))
                                    (cadr (cadr lst))
                                )
                                (vla-put-textstring (last (cadr lst)) new)
                            )
                        )
                    )       
                )
            )
        )

        (princ)

    )

    (_Main)

)
« Last Edit: April 21, 2016, 11:59:15 AM by MP »
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

AIberto

  • Guest
Re: attribute edit
« Reply #7 on: April 16, 2016, 11:11:28 AM »
Code: [Select]
(defun c:MyEd ( / _GetAttDefs _SortAttribsByXY _Main )

< ... >

Good Example. But  have a few flaws.
If attribute block  no prompt .will Error.

in addition. when change attribute Value complete . princ   "Oh my, nothing to do".It is right ?


edit:kdub -> errant code removed as requested
« Last Edit: April 16, 2016, 07:40:55 PM by kdub »

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: attribute edit
« Reply #8 on: April 16, 2016, 12:42:56 PM »
Thank you for trying the program and reporting the problems AIberto.

Fixed in my original post.

An aside, it appears there's a bug in DOSLIB revealed by the first version of the program.

Observe:

Code: [Select]
(dos_proplist "Title" "Description" '(("Prompt" . "Value")))
>> (("Prompt" . "Changed_Value"))  [good]

Code: [Select]
(dos_proplist "Title" "Description" '(("" . "Value")))
>> ("Changed_Value")  [not good]

The function strips the prompt and fubars the list nesting if a prompt is an empty string.

I substituted (chr 160) <non-breaking space> where the prompt string is empty, that seems to remedy it. A one space " " string will suffice too but (chr 160) is explicit in its intention, ergo my use.

Thanks & cheers.

PS: Could you remove the errant code you quoted in your post? Thx.

« Last Edit: April 16, 2016, 04:37:41 PM by MP »
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: attribute edit
« Reply #9 on: April 17, 2016, 09:52:16 AM »
This thread made me think -- is there an easy way to view / modify attribute prompts en masse?

BEdit is not the answer.

Perhaps this is:

Code: [Select]
(defun c:Prompter ( / _Try _GetBlockDefAttDefInfo _Main )

    ;;  C:Prompter. Change the prompts for the selected block.
    ;;
    ;;  Trivial code but still © 2016 Michael Puckett.
    ;;
    ;;  Version 1. 2016-04-17.
    ;;
    ;;  Written very quick & dirty for the swamp. Has bugs and
    ;;  communicable diseases, use at your own risk.   
    ;;
    ;;  Relies on DOSLIB (http://wiki.mcneel.com/doslib/home)

    (defun _Try ( try_statement / try_result )
        (vl-catch-all-apply
            (function
                (lambda ( )
                    (setq try_result (eval try_statement))
                )
            )
        )
        try_result
    )

    (defun _GetBlockDefAttDefInfo ( doc )
        (   (lambda ( :GetAttDefs / result )
                (vlax-for block (vla-get-blocks doc)
                    (and
                        (eq :vlax-false (vla-get-isxref block))
                        (eq :vlax-false (vla-get-islayout block))
                        (setq name (_Try '(vla-get-name block)))
                        (wcmatch name "~`**")
                        (setq attdefs (:GetAttDefs block))
                        (setq result (cons (cons name attdefs) result))
                    )
                )
                (vl-sort result (function (lambda (a b) (< (car a) (car b)))))
            )
            (lambda ( block / result )
                (vlax-for object block
                    (and
                        (eq "AcDbAttributeDefinition" (vla-get-objectname object))
                        (eq :vlax-false (vla-get-constant object))
                        (setq result
                            (cons
                                (list
                                   (vla-get-tagstring object)
                                   (vla-get-promptstring object)
                                    object
                                )
                                result
                            )
                        )
                    )
                )
                (reverse result)
            )
        )
    )
   
    (defun _Main ( / doc BlockDefAttDefInfo next_time name new changes )

        (cond
            (   (null dos_proplist)
                (princ
                    (strcat
                        "\nDo yourself a solid. Download & install DOSLIB."
                        "\tAvailable at http://wiki.mcneel.com/doslib/home."
                    )
                )
            )
            (   (progn (vl-load-com) nil))
            (   (null (setq doc (vla-get-activedocument (vlax-get-acad-object)))))
            (   (null (setq BlockDefAttDefInfo (_GetBlockDefAttDefInfo doc)))
                (princ "\nNo attributed block defs in this drawing.")
            )
            (   (null (setq next_time "\nNothing to do, maybe next time.")))
            (   (null
                    (setq name
                        (dos_listbox
                            "Prompter"
                            "Select an attributed block to modify:"
                            (mapcar 'car BlockDefAttDefInfo)
                        )
                    )
                )
                (princ next_time)
            )
            (   (setq result
                    (dos_proplist "Prompter" "Modify Attribute Prompts:"
                        (mapcar
                            (function (lambda ( a ) (cons (car a) (cadr a))))
                            (setq data (cdr (assoc name BlockDefAttDefInfo)))
                        )
                    )
                )
                (foreach lst (mapcar 'list result data)
                    (if
                        (/=
                            (setq new (cdar lst))
                            (cadr (cadr lst))
                        )
                        (progn
                            (vla-put-promptstring (last (cadr lst)) new)
                            (princ (strcat "\n" (caar lst) " prompt changed to [\"" new "\"]"))
                            (setq changes T)
                        )
                    )
                )
                (if (null changes) (princ next_time))
            )
            (   (princ next_time))
        )

        (princ)

    )

    (_Main)

)

Let me know if it works, fails, other.

Cheers.
« Last Edit: April 17, 2016, 10:06:48 AM by MP »
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

David Bethel

  • Swamp Rat
  • Posts: 656
Re: attribute edit
« Reply #10 on: April 17, 2016, 01:05:09 PM »

One of the problems has always been the ability to modify/edit/remove/add ATTRIButes in the INSERT so that they do match the ATTDEFs in the BLOCK table definition.  DDATTE looks at the BLOCK table for prompts but the INSERT for the data.  -David
R12 Dos - A2K

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: attribute edit
« Reply #11 on: April 18, 2016, 03:04:54 AM »
Strange structure:
Code - Auto/Visual Lisp: [Select]
  1. (foreach lst (mapcar 'list result data)
  2.   ...
  3. )
Why not?:
Code - Auto/Visual Lisp: [Select]
  1.   '(lambda (a b)
  2.     ...
  3.   )
  4.   result
  5.   data
  6. )

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: attribute edit
« Reply #12 on: April 18, 2016, 07:28:32 AM »
@David: Yep. I understand why they did it that way (data efficiency et al) but may not have been the best implementation. If one is manually adding attributes to block insertions one has to be mindful of the block def's sequencing.

@Roy: Lotsa ways to skin the cat, meow. I like strange.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

AIberto

  • Guest
Re: attribute edit
« Reply #13 on: April 18, 2016, 09:09:09 AM »
Hi MP

If "prompt" is empty , that still will be error :
Code: [Select]
Select object: ; error: Unknown exception occurred
; warning: unwind skipped on unknown exception

Create an attribute block.  The tag cannot be empty. the prompt can be empty.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: attribute edit
« Reply #14 on: April 18, 2016, 09:36:10 AM »
Can you post a sample drawing? The program works on the sample dwgs I have that sport attributed blocks with promptless attdefs. Thanks.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

AIberto

  • Guest
Re: attribute edit
« Reply #15 on: April 18, 2016, 10:32:22 AM »
Can you post a sample drawing? The program works on the sample dwgs I have that sport attributed blocks with promptless attdefs. Thanks.

In attachment . Just an attribute block without "prompt"
Code: [Select]
command: MyEd
Select object: ; error: Unknown exception occurred
; warning: unwind skipped on unknown exception
« Last Edit: April 18, 2016, 11:16:54 AM by AIberto »

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: attribute edit
« Reply #16 on: April 18, 2016, 10:35:59 AM »
Thanks AIberto. Could you (or someone else) perform a "SaveAs" down to 2010 format?

I only have AutoCAD 2012 here and no TrueView install.

Thanks and sorry (I should have specified).
« Last Edit: April 18, 2016, 10:49:43 AM by MP »
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

AIberto

  • Guest
Re: attribute edit
« Reply #17 on: April 18, 2016, 11:19:44 AM »
Thanks AIberto. Could you (or someone else) perform a "SaveAs" down to 2010 format?

I only have AutoCAD 2012 here and no TrueView install.

Thanks and sorry (I should have specified).

I'm sorry , MP  ,I forgot converted.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: attribute edit
« Reply #18 on: April 18, 2016, 11:48:06 AM »
Sorry AIberto but that's still a 2013 version dwg.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

ronjonp

  • Needs a day job
  • Posts: 7527
Re: attribute edit
« Reply #19 on: April 18, 2016, 11:51:20 AM »
Sorry AIberto but that's still a 2013 version dwg.
Here you go :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: attribute edit
« Reply #20 on: April 18, 2016, 11:56:25 AM »
Thanks Ronjonp.

Both programs work on the sample drawing without incident.

¯\_(ツ)_/¯
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

AIberto

  • Guest
Re: attribute edit
« Reply #21 on: April 18, 2016, 12:15:09 PM »
Thanks Ronjonp.

Both programs work on the sample drawing without incident.

¯\_(ツ)_/¯


I use different PC, different CAD version (2013, 2010) for test . the same error.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: attribute edit
« Reply #22 on: April 18, 2016, 12:17:24 PM »
Don't know what to tell you, cannot replicate the error here.

Can anyone else replicate the error? Thanks & cheers.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: attribute edit
« Reply #23 on: April 18, 2016, 12:25:32 PM »
Tested here on 2013 ITA, MyEd & Prompter: OK    :-)

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: attribute edit
« Reply #24 on: April 18, 2016, 12:27:28 PM »
Thank you for testing and attesting sir.  :-)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

AIberto

  • Guest
Re: attribute edit
« Reply #25 on: April 18, 2016, 10:04:54 PM »
I use acad2010 ,windows XP sp3 , DOSLib18.arx,

Break at:
Code: [Select]
(dos_proplist "MyEd" "Modify Attributes"
(mapcar
(function (lambda ( a ) (cons (car a) (cadr a))))
attribs
)
)

Tested here on 2013 ITA, MyEd & Prompter: OK    :-)

 mean:  if "prompt" is empty . must use other routine "c:Prompter" to modify attribute prompts , make it not empty .  Then use "Myed" ?

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: attribute edit
« Reply #26 on: April 19, 2016, 02:28:49 AM »
Tested here on 2013 ITA, MyEd & Prompter: OK    :-)

 mean:  if "prompt" is empty . must use other routine "c:Prompter" to modify attribute prompts , make it not empty .  Then use "Myed" ?
No, I used MyEd & Prompter on your file just opened and not modified in two different sessions and loading only one function at a time...  :yes:

AIberto

  • Guest
Re: attribute edit
« Reply #27 on: April 19, 2016, 08:16:44 AM »
Tested here on 2013 ITA, MyEd & Prompter: OK    :-)

 mean:  if "prompt" is empty . must use other routine "c:Prompter" to modify attribute prompts , make it not empty .  Then use "Myed" ?
No, I used MyEd & Prompter on your file just opened and not modified in two different sessions and loading only one function at a time...  :yes:

Dear sir.
I testing. Break at:
Quote
(dos_proplist "MyEd" "Modify Attributes"
   (mapcar
      (function (lambda ( a ) (cons (car a) (cadr a))))
      attribs
   )
)

You analyze why appear error ?

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: attribute edit
« Reply #28 on: April 19, 2016, 10:26:01 AM »
Hi AIberto.
  • While MyEd and Prompter both work with some aspect of attributes they are fully independent.
  • Is DOSLIB (http://wiki.mcneel.com/doslib/home) installed and loaded?
  • Define and load this error handler: (defun *error* (m) (vl-bt)).
  • Execute the program and post the error messages you see.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

AIberto

  • Guest
Re: attribute edit
« Reply #29 on: April 20, 2016, 08:38:41 AM »
Hi AIberto.
  • While MyEd and Prompter both work with some aspect of attributes they are fully independent.
  • Is DOSLIB (http://wiki.mcneel.com/doslib/home) installed and loaded?
  • Define and load this error handler: (defun *error* (m) (vl-bt)).
  • Execute the program and post the error messages you see.

windos xp 32bit+ acad2010 +doslib18.arx
Code: [Select]
DOSLib18.arx successfully loaded.

Command: myed
Select object: ; error: Unknown exception occurred
; warning: unwind skipped on unknown exception

Command: (defun *error* (m) (vl-bt))
*ERROR*

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: attribute edit
« Reply #30 on: April 20, 2016, 08:44:35 AM »
Sorry, unless you provide more info I can't help you.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

AIberto

  • Guest
Re: attribute edit
« Reply #31 on: April 20, 2016, 09:38:41 AM »
Sorry, unless you provide more info I can't help you.

Dear MP

I invited a friend to help me test , He is a  Lisp Master.  At his side. Still Error .



AIberto

  • Guest
Re: attribute edit
« Reply #32 on: April 20, 2016, 09:43:31 AM »
if prompt is empty , test Error.
if prompt is not empty .test ok!

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: attribute edit
« Reply #33 on: April 20, 2016, 09:54:01 AM »
Have LISP master substitute "-" instead of (chr 160).
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

AIberto

  • Guest
Re: attribute edit
« Reply #34 on: April 20, 2016, 11:56:01 AM »
Have LISP master substitute "-" instead of (chr 160).

Dear MP ,I can't understand. :-(

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2132
  • class keyThumper<T>:ILazy<T>
Re: attribute edit
« Reply #35 on: April 20, 2016, 01:19:28 PM »
I'd assume Michael means :
Change this :
Code - Auto/Visual Lisp: [Select]
  1.     (defun _GetPrompt ( attrib / result )
  2.         (if (eq "" (setq result (_Trim (vla-get-promptstring attrib))))
  3.             (chr 160)
  4.             result
  5.         )
  6.     )
  7.  

to this :
Code - Auto/Visual Lisp: [Select]
  1.     (defun _GetPrompt ( attrib / result )
  2.         (if (eq "" (setq result (_Trim (vla-get-promptstring attrib))))
  3.             ;;("-") fix error:kdub
  4.             "-"
  5.             result
  6.         )
  7.     )
  8.  

note : I haven't followed the complete thread so I may be incorrect.

edit:repair error
« Last Edit: April 20, 2016, 01:28:12 PM by kdub »
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: attribute edit
« Reply #36 on: April 20, 2016, 01:21:43 PM »
Yes + thanks. I'm at work and cannot play.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: attribute edit
« Reply #37 on: April 20, 2016, 01:25:48 PM »
Actually "-", not ("-"). Missed as I'm viewing on my diminutive phone. Thx KB.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: attribute edit
« Reply #38 on: April 20, 2016, 03:35:06 PM »
Strange... to me it works without any modification, if I add a print before dos_proplist:
Code: [Select]
...
                   (print
                      (mapcar
                       (function (lambda ( a ) (cons (car a) (cadr a))))
                        attribs
                      )
                    )
                    (setq result
                        (dos_proplist "MyEd" "Modify Attributes"
                            (mapcar
                                (function (lambda ( a ) (cons (car a) (cadr a))))
                                attribs
                            )
                        )
                    ) 
...
    (defun _GetPrompt ( attrib / result )
        (if (eq "" (setq result (_Trim (vla-get-promptstring attrib))))
            (chr 160)
            result
        )
    ) 
I get:

((" " . "Mark") (" " . "Male") (" " . "NO.4") (" " . "15"))
    ^ space

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: attribute edit
« Reply #39 on: April 20, 2016, 03:47:14 PM »
The mod was only meant for AIberto as I suspect the character set on his computer is making DOSLIB chuck a wobbly.

But thanks for testing sir! :)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: attribute edit
« Reply #40 on: April 20, 2016, 04:01:11 PM »
The mod was only meant for AIberto as I suspect the character set on his computer is making DOSLIB chuck a wobbly.

But thanks for testing sir! :)
Prego Brav'uomo.  :wink:

AIberto

  • Guest
Re: attribute edit
« Reply #41 on: April 21, 2016, 06:19:30 AM »
Thanks MP & kb

problem solved ! You're a good guy :smitten:

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
Re: attribute edit
« Reply #42 on: April 21, 2016, 08:40:36 AM »
I had heard of the Turkey test a while ago but I ignored it for the most part; when would my code ever be run by anyone in Turkey (which, after reading up on the subject I learned that, isn't the point) and/but no one, besides me, runs my code. ...The above is a good example of the Turkey test and I think I am finally going to take the problem more seriously and start reading up on it again.

Great detective work, MP!

ref: Turkey test
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: attribute edit
« Reply #43 on: April 21, 2016, 06:54:01 PM »
Thanks AIberto; John.

FYI, I dumped the notion of using the attribute prompts. As David had mentioned, if there is not perfect synchronization between attribute sequencing and the associated block def the prompting would be out of wack. Worse, if attributes instances are created completely independent of a block def, e.g. AutoCAD Electrical, prompts are not to be realized.

The program in my original post was modified accordingly. It still sorts the attributes from top to bottom, left to right, but displays the tags instead of the prompts, thus should work on any insert with attributes, regardless how the attributes were birthed.

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