Jump to content

Recommended Posts

Posted

Hey all,

 

I am working to set up a lisp where the user can edit the titleblock, update revblocks. We have templates that use the "custom" tab on the drawing properties box that tie into the titleblocks we use. I'm looking to just make it so the user can use this lisp instead of opening the dwgprops box everytime.

 

Here's what the dwgprops box looks like:

 

dwg props.PNG

 

This is what I got so far:

 

(defun c:TB ()
 (if (setq Opt
     (getint
       "\nDo you want to: 1- Update Titleblock 2- Update RevBlock 3- Update Drawing Titles: "
     )
     );;user input for variable "opt"
   (progn
     (cond
((= opt 1);;if user picks to update titleblock
 (setq titletop (getstring "\nWhat is title top? "))
 (setq titlemiddle (getstring "\nWhat is title middle? "))
 (setq titlebottom (getstring "\nWhat is title bottom? "))
)
((= opt 2);;if user picks to update revblock
 (setq
   row (getint "\nWhich revision row do you wish to edit? ")
 )
 (progn
   (cond
     ((= row 1)
      (setq 1rowrev (getstring "\n1st row rev: "))
      (setq 1rowyy (getstring "\n1st row year: "))
      (setq 1rowmm (getstring "\n1st row month: "))
      (setq 1rowdd (getstring "\n1st row day: "))
      (setq 1rdesc (getstring T "\n1st row description: "))
      (setq 1rowby (getstring "\n1st row by: "))
      (setq 1rowchk (getstring "\n1st row chk: "))
      (setq 1roweng (getstring "\n1st row eng: "))
      (setq 1rowapp (getstring "\n1st row app: "))
     )
     ((= row 2)
      (setq 2rowrev (getstring "\n2nd row rev: "))
      (setq 2rowyy (getstring "\n2nd row year: "))
      (setq 2rowmm (getstring "\n2nd row month: "))
      (setq 2rowdd (getstring "\n2nd row day: "))
      (setq 2rdesc (getstring T "\n2nd row description: "))
      (setq 2rowby (getstring "\n2nd row by: "))
      (setq 2rowchk (getstring "\n2nd row chk: "))
      (setq 2roweng (getstring "\n2nd row eng: "))
      (setq 2rowapp (getstring "\n2nd row app: "))
     )
     ((= row 3)
      (setq 3rowrev (getstring "\n3rd row rev: "))
      (setq 3rowyy (getstring "\n3rd row year: "))
      (setq 3rowmm (getstring "\n3rd row month: "))
      (setq 3rowdd (getstring "\n3rd row day: "))
      (setq 3rdesc (getstring T "\n3rd row description: "))
      (setq 3rowby (getstring "\n3rd row by: "))
      (setq 3rowchk (getstring "\n3rd row chk: "))
      (setq 3roweng (getstring "\n3rd row eng: "))
      (setq 3rowapp (getstring "\n3rd row app: "))
     )
     ((= row 4)
      (setq 4rowrev (getstring "\n4th row rev: "))
      (setq 4rowyy (getstring "\n4th row year: "))
      (setq 4rowmm (getstring "\n4th row month: "))
      (setq 4rowdd (getstring "\n4th row day: "))
      (setq 4rdesc (getstring T "\n4th row description: "))
      (setq 4rowby (getstring "\n4th row by: "))
      (setq 4rowchk (getstring "\n4th row chk: "))
      (setq 4roweng (getstring "\n4th row eng: "))
      (setq 4rowapp (getstring "\n4th row app: "))
     )
   );;end cond
 );; end progn
);;end opt 2
((= opt 3);;if user picks to update drawing titles, still figuring this section out
)
     );;end cond
   );;end 1st progn
 );;end 1st if
);;end defun

 

What I'm having the hardest time figuring out is how to take the user inputted values and place them into the correct custom drawing properties, this only applies to the revbock updates.

 

I also don't know how to take the title user inputs and put them into the correct drawing property location (although I figure they are closely related)

 

I did find this list which may prove to be helpful in the hunt, but I don't know how to translate it into something useful...

 

2 Title

3 Subject

4 Author

6 Comments

7 Keywords

1 Hyperlink

8 Last saved by

9 Revision

40 Editing time

41 Creation time

42 Last modified time

90 Number of custom properties

300-309 Custom properties

 

Thanks for any and all help!

Posted

Use the properties & methods of the ActiveX SummaryInfo object, derived from the Document object:

(vla-get-summaryinfo (vla-get-activedocument (vlax-get-acad-object)))

Here is a reference: SummaryInfo object

Posted (edited)
Use the properties & methods of the ActiveX SummaryInfo object, derived from the Document object:

(vla-get-summaryinfo (vla-get-activedocument (vlax-get-acad-object)))

Here is a reference: SummaryInfo object

 

Thanks Lee Mac.

 

I don't have any experience with ActiveX but here's a shot in the dark I took.

 

(defun c:TB ()
 (if (setq Opt
     (getint
       "\nDo you want to: 1- Update Titleblock 2- Update RevBlock 3- Update Drawing Titles: "
     )
     );;user input for variable "opt"
   (progn
     (cond
((= opt 1);;if user picks to update titleblock
 (setq titletop (getstring "\nWhat is title top? "))
 (setq titlemiddle (getstring "\nWhat is title middle? "))
 (setq titlebottom (getstring "\nWhat is title bottom? "))
)
((= opt 2);;if user picks to update revblock
 (setq
   row (getint "\nWhich revision row do you wish to edit? ")
 )
 (progn
   (cond
     ((= row 1)
      (setq 1rowrev (getstring "\n1st row rev: "))
      (setq 1rowyy (getstring "\n1st row year: "))
      (setq 1rowmm (getstring "\n1st row month: "))
      (setq 1rowdd (getstring "\n1st row day: "))
      (setq 1rdesc (getstring T "\n1st row description: "))
      (setq 1rowby (getstring "\n1st row by: "))
      (setq 1rowchk (getstring "\n1st row chk: "))
      (setq 1roweng (getstring "\n1st row eng: "))
      (setq 1rowapp (getstring "\n1st row app: "))
      (vla-get-summaryinfo (vla-get-activedocument (vlax-get-acad-object.addcustominfo(1rrev, 1rowrev))))
      )
     ((= row 2)
      (setq 2rowrev (getstring "\n2nd row rev: "))
      (setq 2rowyy (getstring "\n2nd row year: "))
      (setq 2rowmm (getstring "\n2nd row month: "))
      (setq 2rowdd (getstring "\n2nd row day: "))
      (setq 2rdesc (getstring T "\n2nd row description: "))
      (setq 2rowby (getstring "\n2nd row by: "))
      (setq 2rowchk (getstring "\n2nd row chk: "))
      (setq 2roweng (getstring "\n2nd row eng: "))
      (setq 2rowapp (getstring "\n2nd row app: "))
     )
     ((= row 3)
      (setq 3rowrev (getstring "\n3rd row rev: "))
      (setq 3rowyy (getstring "\n3rd row year: "))
      (setq 3rowmm (getstring "\n3rd row month: "))
      (setq 3rowdd (getstring "\n3rd row day: "))
      (setq 3rdesc (getstring T "\n3rd row description: "))
      (setq 3rowby (getstring "\n3rd row by: "))
      (setq 3rowchk (getstring "\n3rd row chk: "))
      (setq 3roweng (getstring "\n3rd row eng: "))
      (setq 3rowapp (getstring "\n3rd row app: "))
     )
     ((= row 4)
      (setq 4rowrev (getstring "\n4th row rev: "))
      (setq 4rowyy (getstring "\n4th row year: "))
      (setq 4rowmm (getstring "\n4th row month: "))
      (setq 4rowdd (getstring "\n4th row day: "))
      (setq 4rdesc (getstring T "\n4th row description: "))
      (setq 4rowby (getstring "\n4th row by: "))
      (setq 4rowchk (getstring "\n4th row chk: "))
      (setq 4roweng (getstring "\n4th row eng: "))
      (setq 4rowapp (getstring "\n4th row app: "))
     )
   );;end cond
 );; end progn
);;end opt 2
((= opt 3);;if user picks to update drawing titles, still figuring this section out
)
     );;end cond
   );;end 1st progn
 );;end 1st if
);;end defun

 

I just tried it with the 1st row rev to see if it would work before trying full on implementation

 

Here is the error I am getting... ; error: no function definition: 1RREV,

 

Any references you can point to that could help me out there?

 

thanks again.

Edited by chiimayred
added clarification
Posted (edited)

Just reading post and I may be wrong but maybe comments based on using plain blocks with attributes, doing a answer for every variable seems difficult and over kill as a line by line type of input.

 

1 Update title block changing only some predefined lines of the title you want to change on all titles, see 7 below

 

2 Update revision just go to a layout "Update rev" automatically knows the block name so searches for the next available blank line and then prompts for user input

 

3 Update title is is a case of say you spell a name wrong or new company so why not just say "enter line No to be updated" "enter Info" then replace in all blocks repeat as required.

 

4 I think its possible to pick a block and return which attribute you have picked in the block and then say update all title blocks to a new value

 

5 You can set limits of which layouts to update.

 

6 Maye use excell link to create a layout / title block details this way you can use copy&paste the spread sheet would be generic for just your title block but any project.

 

7 I have a big project and it auto updates around 20 items in title block which are predefined and reads other info from within dwg.

Edited by BIGAL
Posted (edited)
Use the properties & methods of the ActiveX SummaryInfo object, derived from the Document object:

(vla-get-summaryinfo (vla-get-activedocument (vlax-get-acad-object)))

Here is a reference: SummaryInfo object

 

Had a chance for a second attempt at this... still getting an error. See below for code.

 

(defun c:TB ()
 (vl-load-com)
 (setq doc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
 (setq db (vla-get-Database doc))
 (setq si (vla-get-SummaryInfo db))
 (if (setq Opt
     (getint
       "\nDo you want to: 1- Update Titleblock 2- Update RevBlock 3- Update Drawing Titles: "
     )
     );;user input for variable "opt"
   (progn
     (cond
((= opt 1);;if user picks to update titleblock
 (setq titletop (getstring "\nWhat is title top? "))
 (setq titlemiddle (getstring "\nWhat is title middle? "))
 (setq titlebottom (getstring "\nWhat is title bottom? "))
)
((= opt 2);;if user picks to update revblock
 (setq
   row (getint "\nWhich revision row do you wish to edit? ")
 )
 (progn
   (cond
     ((= row 1)
      (setq 1rowrev (getstring "\n1st row rev: "))
      (setq 1rowyy (getstring "\n1st row year: "))
      (setq 1rowmm (getstring "\n1st row month: "))
      (setq 1rowdd (getstring "\n1st row day: "))
      (setq 1rdesc (getstring T "\n1st row description: "))
      (setq 1rowby (getstring "\n1st row by: "))
      (setq 1rowchk (getstring "\n1st row chk: "))
      (setq 1roweng (getstring "\n1st row eng: "))
      (setq 1rowapp (getstring "\n1st row app: "))
      (vla-SetCustomByIndex(7, 1RREV, 1rowrev))
      )
     ((= row 2)
      (setq 2rowrev (getstring "\n2nd row rev: "))
      (setq 2rowyy (getstring "\n2nd row year: "))
      (setq 2rowmm (getstring "\n2nd row month: "))
      (setq 2rowdd (getstring "\n2nd row day: "))
      (setq 2rdesc (getstring T "\n2nd row description: "))
      (setq 2rowby (getstring "\n2nd row by: "))
      (setq 2rowchk (getstring "\n2nd row chk: "))
      (setq 2roweng (getstring "\n2nd row eng: "))
      (setq 2rowapp (getstring "\n2nd row app: "))
     )
     ((= row 3)
      (setq 3rowrev (getstring "\n3rd row rev: "))
      (setq 3rowyy (getstring "\n3rd row year: "))
      (setq 3rowmm (getstring "\n3rd row month: "))
      (setq 3rowdd (getstring "\n3rd row day: "))
      (setq 3rdesc (getstring T "\n3rd row description: "))
      (setq 3rowby (getstring "\n3rd row by: "))
      (setq 3rowchk (getstring "\n3rd row chk: "))
      (setq 3roweng (getstring "\n3rd row eng: "))
      (setq 3rowapp (getstring "\n3rd row app: "))
     )
     ((= row 4)
      (setq 4rowrev (getstring "\n4th row rev: "))
      (setq 4rowyy (getstring "\n4th row year: "))
      (setq 4rowmm (getstring "\n4th row month: "))
      (setq 4rowdd (getstring "\n4th row day: "))
      (setq 4rdesc (getstring T "\n4th row description: "))
      (setq 4rowby (getstring "\n4th row by: "))
      (setq 4rowchk (getstring "\n4th row chk: "))
      (setq 4roweng (getstring "\n4th row eng: "))
      (setq 4rowapp (getstring "\n4th row app: "))
     )
   );;end cond
 );; end progn
);;end opt 2
((= opt 3);;if user picks to update drawing titles, still figuring this section out
)
     );;end cond
   );;end 1st progn
 );;end 1st if
);;end defun

 

this is the error I am getting:

 

; error: no function definition: 7,

 

Here is there reference page i am using... as well as this one

Edited by chiimayred
corrected code
Posted

(vla-SetCustomByIndex (7, 1RREV, 1rowrev))

[/code]

 

this is the error I am getting:

 

Replace it with the following and try again .

 

(vla-SetCustomByIndex si 7 1RREV 1rowrev)

 

Although I am not sure about the values of the key and value of 1RREV , 1ROWREV

Posted
Replace it with the following and try again .

 

(vla-SetCustomByIndex si 7 1RREV 1rowrev)

 

Although I am not sure about the values of the key and value of 1RREV , 1ROWREV

 

1RREV is the name set in the custom properties tab in the drawing properties for the 1st revision row. If that helps.

 

Updated code and this is the error I get:

 

; error: ActiveX Server returned an error: Parameter not optional
Posted

You have an extra parenthesis and the variable 1RREV has no value which is supposed to be a string , what's more , localize your variables .

Posted (edited)
You have an extra parenthesis and the variable 1RREV has no value which is supposed to be a string , what's more , localize your variables .

 

I ran the VLIDE check and nothing came up for the parenthesis. I have updated the code to localize variables and I'm still getting the same error. See below for updated code.

 

(defun c:TB (/ doc db si opt titletop titlemiddle titlebottom row
     1rowrev 1rowyy 1rowmm 1rowdd 1rowdesc 1rowby 1rowchk 1roweng 1rowapp
     2rowrev 2rowyy 2rowmm 2rowdd 2rowdesc 2rowby 2rowchk 2roweng 2rowapp
     3rowrev 3rowyy 3rowmm 3rowdd 3rowdesc 3rowby 3rowchk 3roweng 3rowapp
     4rowrev 4rowyy 4rowmm 4rowdd 4rowdesc 4rowby 4rowchk 4roweng 4rowapp
     )
 (vl-load-com)
 (setq doc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
 (setq db (vla-get-Database doc))
 (setq si (vla-get-SummaryInfo db))
 (if (setq Opt
     (getint
       "\nDo you want to: 1- Update Titleblock 2- Update RevBlock 3- Update Drawing Titles: "
     )
     );;user input for variable "opt"
   (progn
     (cond
((= opt 1);;if user picks to update titleblock
 (setq titletop (getstring "\nWhat is title top? "))
 (setq titlemiddle (getstring "\nWhat is title middle? "))
 (setq titlebottom (getstring "\nWhat is title bottom? "))
)
((= opt 2);;if user picks to update revblock
 (setq
   row (getint "\nWhich revision row do you wish to edit? ")
 )
 (progn
   (cond
     ((= row 1)
      (setq 1rowrev (getstring "\n1st row rev: "))
      (setq 1rowyy (getstring "\n1st row year: "))
      (setq 1rowmm (getstring "\n1st row month: "))
      (setq 1rowdd (getstring "\n1st row day: "))
      (setq 1rdesc (getstring T "\n1st row description: "))
      (setq 1rowby (getstring "\n1st row by: "))
      (setq 1rowchk (getstring "\n1st row chk: "))
      (setq 1roweng (getstring "\n1st row eng: "))
      (setq 1rowapp (getstring "\n1st row app: "))
      (vla-SetCustomByIndex si 7 1RREV 1rowrev)
      )
     ((= row 2)
      (setq 2rowrev (getstring "\n2nd row rev: "))
      (setq 2rowyy (getstring "\n2nd row year: "))
      (setq 2rowmm (getstring "\n2nd row month: "))
      (setq 2rowdd (getstring "\n2nd row day: "))
      (setq 2rdesc (getstring T "\n2nd row description: "))
      (setq 2rowby (getstring "\n2nd row by: "))
      (setq 2rowchk (getstring "\n2nd row chk: "))
      (setq 2roweng (getstring "\n2nd row eng: "))
      (setq 2rowapp (getstring "\n2nd row app: "))
     )
     ((= row 3)
      (setq 3rowrev (getstring "\n3rd row rev: "))
      (setq 3rowyy (getstring "\n3rd row year: "))
      (setq 3rowmm (getstring "\n3rd row month: "))
      (setq 3rowdd (getstring "\n3rd row day: "))
      (setq 3rdesc (getstring T "\n3rd row description: "))
      (setq 3rowby (getstring "\n3rd row by: "))
      (setq 3rowchk (getstring "\n3rd row chk: "))
      (setq 3roweng (getstring "\n3rd row eng: "))
      (setq 3rowapp (getstring "\n3rd row app: "))
     )
     ((= row 4)
      (setq 4rowrev (getstring "\n4th row rev: "))
      (setq 4rowyy (getstring "\n4th row year: "))
      (setq 4rowmm (getstring "\n4th row month: "))
      (setq 4rowdd (getstring "\n4th row day: "))
      (setq 4rdesc (getstring T "\n4th row description: "))
      (setq 4rowby (getstring "\n4th row by: "))
      (setq 4rowchk (getstring "\n4th row chk: "))
      (setq 4roweng (getstring "\n4th row eng: "))
      (setq 4rowapp (getstring "\n4th row app: "))
     )
   );;end cond
 );; end progn
);;end opt 2
((= opt 3);;if user picks to update drawing titles, still figuring this section out
)
     );;end cond
   );;end 1st progn
 );;end 1st if
);;end defun

Edited by chiimayred
Posted
Had a chance for a second attempt at this... still getting an error. See below for code.

 

      (cond
        ((= row 1)
         (setq 1rowrev (getstring "\n1st row rev: "))
         (setq 1rowyy (getstring "\n1st row year: "))
         (setq 1rowmm (getstring "\n1st row month: "))
         (setq 1rowdd (getstring "\n1st row day: "))
         (setq 1rdesc (getstring T "\n1st row description: "))
         (setq 1rowby (getstring "\n1st row by: "))
         (setq 1rowchk (getstring "\n1st row chk: "))
         (setq 1roweng (getstring "\n1st row eng: "))
         (setq 1rowapp (getstring "\n1st row app: "))
         (vla-SetCustomByIndex(7, 1RREV, 1rowrev))
         [color=blue])[/color] ; This is the extra parentheses so the cond function not allowed to continue to the next row ..

        

 

Again , the variable 1RREV is nil which is supposed to be string. or maybe the variable name must be 1rowrev

Posted
Again , the variable 1RREV is nil which is supposed to be string. or maybe the variable name must be 1rowrev

 

I'll look into that...

 

I updated the code and attached a drawing with the custom properties... please check post here

Posted
Again , the variable 1RREV is nil which is supposed to be string. or maybe the variable name must be 1rowrev

 

I figured it out! Found this resource

 

Here is the updated code for that one line. I'll report back when I get all of it done...

 

(defun c:TB ( / doc db si opt titletop titlemiddle titlebottom row
     1rowrev 1rowyy 1rowmm 1rowdd 1rowdesc 1rowby 1rowchk 1roweng 1rowapp
     2rowrev 2rowyy 2rowmm 2rowdd 2rowdesc 2rowby 2rowchk 2roweng 2rowapp
     3rowrev 3rowyy 3rowmm 3rowdd 3rowdesc 3rowby 3rowchk 3roweng 3rowapp
     4rowrev 4rowyy 4rowmm 4rowdd 4rowdesc 4rowby 4rowchk 4roweng 4rowapp
     )
 (vl-load-com)
 (setq acadObject (vlax-get-Acad-Object))
 (setq acadDocument (vla-get-Activedocument acadObject))
 (setq dProps (vlax-get-property acadDocument 'Summaryinfo))
 (if (setq Opt
     (getint
       "\nDo you want to: 1- Update Titleblock 2- Update RevBlock 3- Update Drawing Titles: "
     )
     );;user input for variable "opt"
   (progn
     (cond
((= opt 1);;if user picks to update titleblock
 (setq titletop (getstring "\nWhat is title top? "))
 (setq titlemiddle (getstring "\nWhat is title middle? "))
 (setq titlebottom (getstring "\nWhat is title bottom? "))
)
((= opt 2);;if user picks to update revblock
 (setq
   row (getint "\nWhich revision row do you wish to edit? ")
 )
 (progn
   (cond
     ((= row 1)
      (setq 1rowrev (getstring "\n1st row rev: "))
      (setq 1rowyy (getstring "\n1st row year: "))
      (setq 1rowmm (getstring "\n1st row month: "))
      (setq 1rowdd (getstring "\n1st row day: "))
      (setq 1rdesc (getstring T "\n1st row description: "))
      (setq 1rowby (getstring "\n1st row by: "))
      (setq 1rowchk (getstring "\n1st row chk: "))
      (setq 1roweng (getstring "\n1st row eng: "))
      (setq 1rowapp (getstring "\n1st row app: "))
      (vla-SetCustomByIndex dProps 7 "1RREV" 1rowrev)
      );;end row=1
     ((= row 2)
      (setq 2rowrev (getstring "\n2nd row rev: "))
      (setq 2rowyy (getstring "\n2nd row year: "))
      (setq 2rowmm (getstring "\n2nd row month: "))
      (setq 2rowdd (getstring "\n2nd row day: "))
      (setq 2rdesc (getstring T "\n2nd row description: "))
      (setq 2rowby (getstring "\n2nd row by: "))
      (setq 2rowchk (getstring "\n2nd row chk: "))
      (setq 2roweng (getstring "\n2nd row eng: "))
      (setq 2rowapp (getstring "\n2nd row app: "))
     );;end row=2
     ((= row 3)
      (setq 3rowrev (getstring "\n3rd row rev: "))
      (setq 3rowyy (getstring "\n3rd row year: "))
      (setq 3rowmm (getstring "\n3rd row month: "))
      (setq 3rowdd (getstring "\n3rd row day: "))
      (setq 3rdesc (getstring T "\n3rd row description: "))
      (setq 3rowby (getstring "\n3rd row by: "))
      (setq 3rowchk (getstring "\n3rd row chk: "))
      (setq 3roweng (getstring "\n3rd row eng: "))
      (setq 3rowapp (getstring "\n3rd row app: "))
     );;end row=3
     ((= row 4)
      (setq 4rowrev (getstring "\n4th row rev: "))
      (setq 4rowyy (getstring "\n4th row year: "))
      (setq 4rowmm (getstring "\n4th row month: "))
      (setq 4rowdd (getstring "\n4th row day: "))
      (setq 4rdesc (getstring T "\n4th row description: "))
      (setq 4rowby (getstring "\n4th row by: "))
      (setq 4rowchk (getstring "\n4th row chk: "))
      (setq 4roweng (getstring "\n4th row eng: "))
      (setq 4rowapp (getstring "\n4th row app: "))
     );;end row=4
   );;end cond
 );; end progn
);;end opt 2
((= opt 3);;if user picks to update drawing titles, still figuring this section out
)
     );;end cond
   );;end 1st progn
 );;end 1st if
);;end defun

Posted (edited)

You could save yourself a lot of variable naming by creating a list, see below works for all rows...

 

(foreach x '("rev: " "year: " "month: " "day: " "description: " "by: " "chk: " "eng: " "app: ")
 (setq rowL (cons  (getstring (strcat "\nRow # " (itoa row) " - " x)) rowL))
 )
(setq rowL (reverse rowL))

 

Then utilize the "nth" function for retrieving data to place in drawing.

 

Bruce

Edited by Snownut

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...