Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Delete DWG File Properties

7 REPLIES 7
Reply
Message 1 of 8
braydon.visser
3813 Views, 7 Replies

Delete DWG File Properties

I am looking for code that will delete all the properties within a DWG file. Can anyone help?

Searching the forum, I found the following code:

; Remove any existing Properties
(dictremove (namedobjdict) "DWGPROPS")


However, further research (forum, testing and help system) indicates that it no longer applies to current releases of AutoCAD so my initial happiness was short-lived!

Thankyou kindly,

Braydon

7 REPLIES 7
Message 2 of 8
_gile
in reply to: braydon.visser

Hi,

You can try this:

{code};; get the SummaryInfo object
(setq sinfo (vla-get-SummaryInfo (vla-get-ActiveDocument (vlax-get-acad-object))))

;; remove custom infos
(repeat (setq n (vla-NumCustomInfo sinfo))
(vla-RemoveCustomByIndex sinfo (setq n (1- n)))
)

;; remove summary infos
(foreach prop '(Author Comments Hyperlinkbase
Keywords LastSavedBy RevisionNumber
Subject Title
)
(if (vlax-property-available-p sinfo prop T)
(vlax-put-property sinfo prop "")
)
){code}


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 8
devitg
in reply to: braydon.visser

Hi Gile , Itry to add a new key as follow


[code] (vla-addcustominfo sinfo "I do it " (rtos (getvar 'cdate)2 6)) [/code][code] (setq prop "I do it ") (if (vlax-property-available-p sinfo prop T) (princ (vlax-get-property sinfo prop )) ) [/code]

How can I retrieve it ?

I try

[code]
(setq prop "I do it ")
(if (vlax-property-available-p sinfo prop T)
(princ (vlax-get-property sinfo prop ))
)
[/code]

"I do it "
nil






Message 4 of 8
devitg
in reply to: braydon.visser

Hi Gile , Itry to add a new key as follow


[code] (vla-addcustominfo sinfo "I do it " (rtos (getvar 'cdate)2 6)) [/code][code] (setq prop "I do it ") (if (vlax-property-available-p sinfo prop T) (princ (vlax-get-property sinfo prop )) ) [/code]

How can I retrieve it ?

I try

[code]
(setq prop "I do it ")
(if (vlax-property-available-p sinfo prop T)
(princ (vlax-get-property sinfo prop ))
)
[/code]

"I do it "
nil






Message 5 of 8
_gile
in reply to: braydon.visser

Hi,

Try this:

{code}(vla-GetCustomByKey sinfo "I do it " 'pValue){code}

The value is stored in pVaue variable.


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 6 of 8
devitg
in reply to: braydon.visser

Hi Gile , like the BOUNDINGBOX method .

So ,
{code:java}vla-GetCustomByKey{code}
is a method .


I see it now

#<VLA-OBJECT IAcadSummaryInfo 1c33ae34>
; IAcadSummaryInfo: IAcadSummaryInfo Interface
; Property values:
; Author = ""
; Comments = ""
; HyperlinkBase = ""
; Keywords = ""
; LastSavedBy = "Administrador"
; RevisionNumber = ""
; Subject = ""
; Title = ""
; Methods supported:
; AddCustomInfo (2)
; GetCustomByIndex (3)
; GetCustomByKey (2)
; NumCustomInfo ()
; RemoveCustomByIndex (1)
; RemoveCustomByKey (1)
; SetCustomByIndex (3)
; SetCustomByKey (2)

T

Edited by: DEVITG on Mar 6, 2010 2:10 PM
Message 7 of 8
Hammer.john.j
in reply to: devitg

could somebody describe how to load this and run it, i want to do the same thing on some old files, thanks.
John Hammer, LA/CADD Manager
Message 8 of 8

Hammer, just saw your old post.  To use this code, you have to "wrap" it in a defun.  Whatever that is, but it really is FUN!  JK.  It means something like define function, which means it makes the code snippet pasted above act like a little mini-program.  If you put a C:thisismycommandname in front of it, then you can type the command name after the C: part and it will run that mini-program in your cad.  The braniacs that post all these gems, have a secret code of ethics which involves leaving just enough of the code out to make it NOT run by just copying and pasting.  The intent is to force you to learn how to start writing your own lisp code.  So get started!

 

So to summarize and get started writing your own code, follow these steps.

 

1.  Find the code that was so generously donated.

 

2. Copy that code.  Be sure that you get only lines that will run in a lisp. A good starting point is usually the double semi-colon.  This is a "comment" line and will not run, but it usually tells you where the code starts and tells you about the function code.

 

3. In the example that _gile shared, copy all the text between the {code} markers.  Leave the {code} out of your selection set.

 

4. Go to your desktop.

 

5. Make a new text or .txt file.

 

6.  Open that new .txt file.

 

7.  Paste your copied code.

 

8.  Now it's time to "wrap" that code snippet in a function.

 

9.  Make a blank line at the top of the text file.

 

10. On the top, blank line, type just the following        (defun C:DelCustomProps ( / )

 

11.  Make a blank line at the bottom of your text file.

 

12.  Type just the following       )

 

13.  That last parenthesis "closes" the mini-program or function.

 

14.  Go into your cad and on the command line, type the following     appload

 

15.  A window will open.  Browse to your desktop and choose the .txt file that you created on your desktop.

 

16.  Click on the "load" button.  The mini-program is loaded into cad memory.

 

17.  To run your mini-program, type just the command name that comes after the C: in your .txt file.

 

18.  In this example, you would just type the following        DelCustomProps

 

19.  Your program will now begin running.

 

20.  If the mini-program was written to ask for input, just pay attention to your command line and do what you are prompted to.

 

21.  Congratulations.  You "wrote" your very first lisp routine.  It's a small step, but it's how everyone in these forums got started.

 

22.  Keep at it.  Keep on learning.  You will begin recognizing patterns and wondering how you would write something like that.

 

23.  Try mashing some different lisps together.  Make them do new things.  Share what you create.  Keep the sharecycle going.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost