TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: T.Willey on December 23, 2005, 07:07:45 PM

Title: Just for fun. Make a dialog box of all editable properties per object.
Post by: T.Willey on December 23, 2005, 07:07:45 PM
I have this code working.  The problem now is that it isn't grabbing all the information for blocks.  It is leaving out the scale values, and I'm not sure why.  The way the code works, because it's the only way I found out how to do it, is once you pick and object, it prints to the command line the properties via (vlax-dump-object.... ).  But before that, it tells acad that it wants to keep up the log file, this is how I grab all the properties.  If anyone knows a better way, I'm all ears.  I will post the file because the code looks pretty nasty.

Any help is appreciated. Thanks in advance.  And Happy Holidays to All.
Tim

ps.  I couldn't get the while to loop right, that is why it is commented out in the code.
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: MP on December 23, 2005, 07:51:06 PM
You mean something like this (http://www.theswamp.org/forum/index.php?topic=5185.msg62997#msg62997)?
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: T.Willey on December 24, 2005, 04:54:43 AM
Yea.  That looks like what I was trying to do (but a whole lot nicer).  Can you tell me how you got there?  If not I understand.  Maybe a hint then.  The way I'm doing it is not the best, and your looks a lot better.  I don't know if I can dl and use a fas at work.  Then don't want me doing stuff like that.

Thanks.
Tim
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: MP on December 24, 2005, 07:58:06 AM
Hint: I walk the atoms family, pulling out properties / methods as available / applicable for the object selected.
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: nivuahc on December 24, 2005, 08:04:56 AM
<Lurch> You raaaang? </Lurch>
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: MP on December 24, 2005, 08:23:34 AM
<Lurch> You raaaang? </Lurch>

<canajun> eh? </canajun>
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: nivuahc on December 24, 2005, 08:29:45 AM
Hint: I walk the atoms family...

Maybe I'm showing my age
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: MP on December 24, 2005, 08:36:57 AM
Dang, that's funny Chuck, I'm embarrassed I needed 'splainin'. I remember the original too.  :oops:

There was a point as kids when we were referred to as "Cousin Its" because of the long hair thang (gone now).
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: nivuahc on December 24, 2005, 08:41:00 AM
That's funny, my Mom always called me Fester (http://dictionary.reference.com/search?q=fester&db=*)

I think it had something to do with my bathing habits (or lack thereof).
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: MP on December 24, 2005, 08:44:31 AM
Let me guess, your feet smelled like cheese.

 :-o
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: nivuahc on December 24, 2005, 08:47:10 AM
Limburger  :oops:
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: T.Willey on December 24, 2005, 04:42:01 PM
Hint: I walk the atoms family, pulling out properties / methods as available / applicable for the object selected.
Thanks Michael.  I will work on this one Tuesday when I get back to work and Acad.  I have not worked at all with atoms, so this will be a good learning experience.

Hope everyone gets what they want from the Holidays.
Tim
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: MP on December 24, 2005, 07:59:33 PM
Hi Tim, these snips may prove useful --

GetVlaAtoms

Code: [Select]
(defun GetVlaAtoms ( )
    (vl-remove-if-not
       '(lambda (symbol)   
            (wcmatch
                (vl-symbol-name symbol)
                "vla-*"
            )
        )
        (atoms-family 0)
    )
)

GetVlaProperties

Code: [Select]
(defun GetVlaProperties ( atoms )
    (vl-sort
        (mapcar
           '(lambda (symbolname) (substr symbolname 9))
            (vl-remove-if-not
               '(lambda (symbolname)   
                    (wcmatch
                        symbolname
                        "vla-get-*" ;; don't need 'put'
                    )
                )
                (mapcar 'vl-symbol-name atoms)
            )
        )
        '<
    )   
)

GetVlaMethods

Code: [Select]
(defun GetVlaMethods ( atoms )
    (vl-sort
        (mapcar
           '(lambda (symbolname) (substr symbolname 5))
            (vl-remove-if
               '(lambda (symbolname)   
                    (wcmatch
                        symbolname
                        "vla-get-*,vla-put-*" ;; need 'put'
                    )
                )
                (mapcar 'vl-symbol-name atoms)
            )
        )   
       '<
    )   
)

Use GetVlaAtoms to get the initial susbset of vla-* atoms, then pass said subset to GetVlaProperties and GetVlaMethods to get the properties and methods respectively (as opposed to multiple atoms-family calls which would be somewhat less efficient).

Another note: You may think GetVlaProperties and GetVlaMethods are the same, but they're not -- note the use of vl-remove-if-not and vl-remove-if respectively and the filtering arguments employed. I know they both could have been written generically as one function that takes more arguments but I didn't see the need as they'd only be used these two ways.

Sorry for the bla bla bla part, can't help myself.
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: GDF on December 26, 2005, 08:36:34 AM
Tim

Take a look at this one by Michael Puckett.

Gary
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: GDF on December 26, 2005, 10:04:05 AM
Tim

Really like your test version. I didn't realize that you could modify the properties with it, upon my first test.
Can't wait for your next version.

Gary
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: GDF on December 27, 2005, 08:31:07 AM
Tim

Just a quick note, the routine does not work on plines:

* Select object [Nested level] *; IAcadLWPolyline: AutoCAD Lightweight Polyline
Interface
; Property values:
;   Application (RO) = #<VLA-OBJECT IAcadApplication 00c2eb8c>
;   Area (RO) = 0.0
;   Closed = 0
;   ConstantWidth = 0.0
;   Coordinate = ...Indexed contents not shown...
;   Coordinates = (-1.56607 10.6713 18.1333 10.6713)
;   Document (RO) = #<VLA-OBJECT IAcadDocument 0d7df554>
;   Elevation = 0.0
;   Handle (RO) = "7D"
;   HasExtensionDictionary (RO) = 0
;   Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 0febcea4>
;   Layer = "0"
;   Length (RO) = 19.6994
;   Linetype = "ByLayer"
;   LinetypeGeneration = 0
;   LinetypeScale = 1.0
;   Lineweight = -1
;   Normal = (0.0 0.0 1.0)
;   ObjectID (RO) = 2130165352
;   ObjectName (RO) = "AcDbPolyline"
;   OwnerID (RO) = 2130164984
;   Pl
 Error --> Invalid number of parameters
Command:

Gary
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: whdjr on December 27, 2005, 10:27:40 AM
Tim,

Here's (http://www.theswamp.org/forum/index.php?topic=7113.msg87386#msg87386) one I wrote for attributes that gives you a variable dialog box with all the attributes listed for the selected block.  Then it allows you to match any selected attributes from the reference block to selected blocks.
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: T.Willey on December 27, 2005, 11:10:13 AM
Thanks Michael.  Those will be a big help.  I want to understand what they are doing, so I will study the help guide, and other information I can find.  With what you posted, would you suggest getting a list of all the properties and methods per drawing, and then just filtering per object selected?  I am learning that way, thinking of speed.

Thanks Gary.  I was having problems on blocks.  It would hang up when there was complex objects it seems.  I think with the help from MP (code provided, and knowledge) this will be a useful tool, and fun to code, and a great learning experience.

Thanks Will for the link.  I will test it when I get a chance.  It looks helpful.

Off to learn some things in the help and so forth.
Tim
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: T.Willey on December 27, 2005, 03:07:40 PM
I'm having a little problem. When I exit the dialog box, I run this routine to check to see if anything has changed.
Code: [Select]
(defun EditObjectsProperties (/ NewValue OldValue)

(mapcar
 '(lambda (x)
(if
(and
(/= (get_tile x) "*Error getting value!!")
(not
(equal
(setq NewValue
(cond
((= (strcase x) "LAYER")
(nth (atoi (get_tile x)) LayList)
)
((= (strcase x) "LINETYPE")
(nth (atoi (get_tile x)) LTList)
)
((= (strcase x) "STYLENAME")
(nth (atoi (get_tile x)) StyList)
)
((= (strcase x) "TEXTSTYLE")
(nth (atoi (get_tile x)) StyList)
)
(t
(get_tile x)
)
)
)
(setq OldValue (vlax-get tmpObj x))
0.001
)
)
(vlax-property-available-p tmpObj x T)
)
(if
(vl-catch-all-error-p
(vl-catch-all-apply 'vlax-put (list tmpObj x NewValue))
)
(prompt (strcat "\n Could not update property \"" x "\"!!" (vl-princ-to-string OldValue) " " (vl-princ-to-string NewValue)))
(prompt (strcat "\n---- Updated property \"" x "\""))
)
)
 )
 PropList
)
)
PropList = List of available properties
tmpObj = Is the object selected to be changed.
All the prompts are for error testing.

My test does not seem to work the way I think it should. He is a copy from the command line.
Quote
Command:
EDITPROPERTIES
 Select object to edit properties:
---- Updated property "Color"
 Could not update property "EndPoint"!!(9.73584 2.95454 0.0) (9.73584 2.95454 0.0)
---- Updated property "LinetypeScale"
---- Updated property "LineWeight"
 Could not update property "Normal"!!(0.0 0.0 1.0) (0.0 0.0 1.0)
 Could not update property "StartPoint"!!(3.43571 5.64089 0.0) (3.43571 5.64089 0.0)
---- Updated property "Thickness"
 Could not update property "TrueColor"!!#<VLA-OBJECT IAcadAcCmColor 193188e0> #<VLA-OBJECT IAcadAcCmColor 19320220>
---- Updated property "Visible"

I didn't even change anything, but my test thinks I did. How can I code this better to have it only change (or try) items that have been changed in the dialog box?

Another question:
I'm not sure if this is possible. When the item to change is a point I'm trying to have the user be able to either select a point, or type it in. I have the code to add a pick button next to the edit box when the current point value is displayed. I know I need an action tile for the button, but is there any way to write one on the fly? I was thinking of maybe writing a lisp to a temp file, load it, then delete it, but I'm not sure if that will work. Or is there a way to just write the action tile to the command line?

Thanks for any tips, answers, anything really. The code kind of works, so if you need the code I can post the whole thing.
Tim
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: T.Willey on December 27, 2005, 03:58:11 PM
I figured out my check. I was comparing strings to reals, integers and lists. I had to convert them back to what they should be. I still don't have an answer to this.
Another question:
I'm not sure if this is possible. When the item to change is a point I'm trying to have the user be able to either select a point, or type it in. I have the code to add a pick button next to the edit box when the current point value is displayed. I know I need an action tile for the button, but is there any way to write one on the fly? I was thinking of maybe writing a lisp to a temp file, load it, then delete it, but I'm not sure if that will work. Or is there a way to just write the action tile to the command line?

Thanks.
Tim
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: T.Willey on December 27, 2005, 04:15:31 PM
It works for me now, but not with all the bells and whistles that I want. I will continue to work on this. Feel free to leave any feed back here.

Tim

Edit: Added an Undo mark to the routine, and posted the new file.
Edit: Attached file with corrections mentioned below.  Thanks.
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: deegeecees on December 27, 2005, 04:34:55 PM
Here's what it gave me Tim:

Quote
Command: (load"grabproperties")

 -- type "EditProperties" to use."\n -- type \"EditProperties\" to use."

Command: editproperties

 Error --> no function definition: VL-STARTUNDOMARK
Command:
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: Kerry on December 27, 2005, 04:40:00 PM
That would probably be meant to be
(vla-StartUndoMark
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: T.Willey on December 27, 2005, 05:06:12 PM
That would probably be meant to be
(vla-StartUndoMark
Yup. Sorry about that.
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: deegeecees on December 27, 2005, 05:07:46 PM
Updating...
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: deegeecees on December 27, 2005, 05:23:13 PM
... and now:

It just dumps what looks like a DCL file to be written "on-the-fly" to the text screen and gives me the old streamp carp:

Quote
Error --> bad argument type: streamp nil

Granted I'm using 2002 for testing, will try in 2004, please hold...


... nope, same thing in 2004. FYI.

Happy coding.
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: T.Willey on December 27, 2005, 05:36:02 PM
Thanks Kerry for answering these.  I can check more often, so that you don't have to do so much work. :-)

Tim
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: Kerry on December 27, 2005, 05:38:08 PM
That's OK Tim, I just happened to be riding past. :wink:

.. and, I removed my post regarding folders, cause that was a guess ..
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: T.Willey on December 27, 2005, 05:38:51 PM
You can try changing the direction of the file. Right now it's coded to go to the temp folder, but if you can't write to that location, then you can change it. Change this line to a directory you have read/write access to.
Code: [Select]
(setq DiaFile "c:/temp/tmpPropertyDialog.dcl")

Tim
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: T.Willey on December 28, 2005, 04:10:55 PM
I have been beaten :-(.  I can not figure out how to do it the way I want, so I went another way.  I use a list box instead of all the edit boxes.  I am attaching the lisp and the dcl file.  Let me know if anyone finds it useful.  Thanks to all for all the help I have received here.
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: CAB on December 28, 2005, 10:38:18 PM
Tim,
I like this version better.
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: Kerry on December 28, 2005, 10:41:01 PM
Tim, Do you use DosLib ?

Have a look at the dos_proplist  
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: Kerry on December 28, 2005, 10:42:53 PM
.. You may have to use something like ObjectDCL to get the fully interactive result you want though, I think.
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: T.Willey on December 29, 2005, 02:35:12 AM
Tim, Do you use DosLib ?

Have a look at the dos_proplist  
I try not to use outside programs.  I have it installed at work, but I havn't used it.  The company I work for has code writes, or hired coders that use it.  I have no idea what all DosLib can do.

Tim,
I like this version better.

Thanks CAB.  I think it functions a lot better also.  I hope Michael doesn't mind me posting the code.  It kind of looks like his routine now.
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: GDF on December 29, 2005, 09:51:46 AM
Way to go Tim. I like this newer version better to.

Also have you looked at:
;;;    LSPDATA.lsp- Express Tool data for lsp command
;;;    Copyright 1999 by Autodesk, Inc.


Gary
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: T.Willey on December 29, 2005, 11:17:12 AM
Way to go Tim. I like this newer version better to.

Also have you looked at:
;;; LSPDATA.lsp- Express Tool data for lsp command
;;; Copyright 1999 by Autodesk, Inc.


Gary

Thanks Gary, and I never knew about that one either.  I guess I know enough to be dangerous, but not enough still.

I saw a post that MP did that shows how to get to the help files, and I was going to add that to my code also, but then it would work a LOT like his code, so i would rather get his blessing before I do that.  I have it working here.  I think it can be a big help if people don't know what information (type) to enter for new values.

Thanks again all who have helped, and tested it. :-)
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: GDF on December 30, 2005, 02:41:36 PM
Tim

Just could not keep my hands off it...hope you don't mind. Made minor dcl changes.
Thanks for sharing your routine.

Gary
Title: Re: Just for fun. Make a dialog box of all editable properties per object.
Post by: T.Willey on December 30, 2005, 03:01:52 PM
Tim

Just could not keep my hands off it...hope you don't mind. Made minor dcl changes.
Thanks for sharing your routine.

Gary
:lmao:
Some how I knew that if you were going to use it, you would change it somehow. It's all good as long as you find it useful. Have fun with it, and may you have a Happy New Years.