Jump to content

Using LISP to Populate Drawing Properties Fields


Bill Tillman

Recommended Posts

Can anyone point me in the right direction to find out how to populate the drawing properties fields using LISP or is this a task better handled by .NET method?

 

By drawing properties I am referring to when you select the File menu and choose Drawing Properties. I see that is uses the command _dwgprops and now I'd like to find information on how to populate the fields like "Author" "Keywords" as well as to create and populate some custom fields.

Edited by Bill Tillman
Link to comment
Share on other sites

I hate to update my own posts but it's been another one of those frustrating days or searching and finding BS answers, empty answers, no answers, answers that don't work or don't include all the needed info...and all from some *&^% who thinks the whole world should know as much about the question as they do.

 

Anyway, AfraLISP had a promising block of code...but it too would not work reporting back error after error...Wrong DXF code, etc.. But I did at least find this so for those who'd like at least something to get started with this topic:

(defun addsummaryinfo (/ suminfo)
 (setq	suminfo	(vla-get-summaryinfo
	  (vla-get-activedocument
	    (vlax-get-acad-object)
	  )
	)
 )
 (vla-put-author suminfo (getenv "username"))
 (vla-put-comments suminfo "These are the comments")
 (vla-put-hyperlinkbase suminfo "")
 (vla-put-keywords suminfo "These are the keywords")
 (vla-put-lastsavedby suminfo (getenv "username"))
 (vla-put-revisionnumber suminfo "123456")
 (vla-put-subject suminfo "This is the subject")
 (vla-put-title
   suminfo
   (strcat (getvar 'dwgprefix) (getvar 'dwgname))
 )
 (princ)
)

Link to comment
Share on other sites

I'll offer this as a no answer at all.

 

I have used this in VBA to populate the custom properties. There may be something in it to give you a clue.

 

Private Sub cmdUpdate_Click()
   Dim Key0 As String
   Dim Value0 As String
   Dim Key1 As String
   Dim Value1 As String
   Dim CustomProperty1 As String
   Dim Property1Value As String
   Dim CustomProperty2 As String
   Dim Property2Value As String
   
   CustomProperty1 = "RigName"
   Property1Value = txtRigName.Text
   CustomProperty2 = "STL_Number"
   Property2Value = txtSTL_Number.Text
   Key0 = CustomProperty1
   ThisDrawing.SummaryInfo.SetCustomByKey CustomProperty1, Property1Value
   
   Key1 = CustomProperty2
   ThisDrawing.SummaryInfo.SetCustomByKey CustomProperty2, Property2Value
Me.Hide
End Sub

 

It is a long time since I last looked at this code. I was using it to prove we could speed up production of some similar produces but apparently it was too difficult to do it my way. Far better to throw people at the task.

Link to comment
Share on other sites

It may help

;; get the summaryinfo object
(setq suminfo (vla-get-SummaryInfo
 (vla-get-ActiveDocument (vlax-get-acad-object))
      )
)
;; get the summary infos
(foreach prop '(Author        Comments       Hyperlinkbase  Keywords
 LastSavedBy    RevisionNumber Subject      Title
       )
 (setq PropLst (cons (list prop (vlax-get-property suminfo prop)) PropLst))
)

;; get custom infos
(if (> (setq n (vla-NumCustomInfo suminfo)) 0)
 (repeat n
   (vla-GetCustomByIndex suminfo (setq n (1- n)) 'a 'b)
   (setq PropLst (cons (list n a b) PropLst))
 )
)
;; reverse the PropLst to the correct order
(setq PropLst (reverse PropLst))

;; remove summary infos
(foreach prop '(Author        Comments       Hyperlinkbase  Keywords
 LastSavedBy    RevisionNumber Subject      Title
       )
 (vlax-put-property suminfo prop "")
)
;; remove custom infos
(repeat (setq n (vla-NumCustomInfo suminfo))
 (vla-RemoveCustomByIndex suminfo (setq n (1- n)))
)
;; set summary info
(vlax-put-property suminfo TheProperty "The prop string")
;; add custom info 
(vla-AddCustomInfo suminfo "Prop" "The prop value")
;; set custom info by index
(vla-SetCustomByIndex suminfo 0 "Prop" "The prop value")
;; set custom info by Key
(vla-SetCustomByKey suminfo "Prop" "New prop value")
;; get custom info by index
(vla-GetCustomByIndex suminfo 0 "Prop" 'a)
;; get custom info by Key
(vla-GetCustomByKey suminfo "Prop" 'a)

 

Henrique

Link to comment
Share on other sites

  • 6 years later...
10 hours ago, nolex said:

How do you guys run this code? Can this still be loaded through appload command in autocad?

 

Hmsilva didn't post a complete lips code just examples for Bill to use. dbroada posted vba code that i think you need to install a VBA add-in to use inside AutoCAD.

 

What are you looking to do?

 

--edit

 

this might be what your looking for

https://adndevblog.typepad.com/autocad/2012/08/lisp-example-for-setting-and-getting-drawing-properties.html

Edited by mhupp
website
  • Like 1
Link to comment
Share on other sites

  • Bill Tillman changed the title to Using LISP to Populate Drawing Properties Fields

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...