TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started 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.
-
You mean something like this (http://www.theswamp.org/forum/index.php?topic=5185.msg62997#msg62997)?
-
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
-
Hint: I walk the atoms family, pulling out properties / methods as available / applicable for the object selected.
-
<Lurch> You raaaang? </Lurch>
-
<Lurch> You raaaang? </Lurch>
<canajun> eh? </canajun>
-
Hint: I walk the atoms family...
Maybe I'm showing my age
-
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).
-
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).
-
Let me guess, your feet smelled like cheese.
:-o
-
Limburger :oops:
-
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
-
Hi Tim, these snips may prove useful --
GetVlaAtoms
(defun GetVlaAtoms ( )
(vl-remove-if-not
'(lambda (symbol)
(wcmatch
(vl-symbol-name symbol)
"vla-*"
)
)
(atoms-family 0)
)
)
GetVlaProperties
(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
(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.
-
Tim
Take a look at this one by Michael Puckett.
Gary
-
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
-
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
-
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.
-
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
-
I'm having a little problem. When I exit the dialog box, I run this routine to check to see if anything has changed.
(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.
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
-
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
-
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.
-
Here's what it gave me Tim:
Command: (load"grabproperties")
-- type "EditProperties" to use."\n -- type \"EditProperties\" to use."
Command: editproperties
Error --> no function definition: VL-STARTUNDOMARK
Command:
-
That would probably be meant to be
(vla-StartUndoMark
-
That would probably be meant to be
(vla-StartUndoMark
Yup. Sorry about that.
-
Updating...
-
... 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:
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.
-
Thanks Kerry for answering these. I can check more often, so that you don't have to do so much work. :-)
Tim
-
That's OK Tim, I just happened to be riding past. :wink:
.. and, I removed my post regarding folders, cause that was a guess ..
-
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.
(setq DiaFile "c:/temp/tmpPropertyDialog.dcl")
Tim
-
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.
-
Tim,
I like this version better.
-
Tim, Do you use DosLib ?
Have a look at the dos_proplist
-
.. You may have to use something like ObjectDCL to get the fully interactive result you want though, I think.
-
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.
-
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
-
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. :-)
-
Tim
Just could not keep my hands off it...hope you don't mind. Made minor dcl changes.
Thanks for sharing your routine.
Gary
-
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.