Add another Attribute in same block and outputs values in tables

Add another Attribute in same block and outputs values in tables

mint09
Enthusiast Enthusiast
1,803 Views
15 Replies
Message 1 of 16

Add another Attribute in same block and outputs values in tables

mint09
Enthusiast
Enthusiast

Need a small help to modify a lisp. The lisp attached above is working, Normally command 'CN' allow me to place a "CRBLK" block with incremental number for ATT TAG "00" as i click where i wants.
Just need some small modifications to add 
another Attribute in same block with value "IL=00" which will be constant(NON INCREMENTAL) .

and later when using command "FCRT", it'll also gives the output as ATT tag values then coordinates then Second ATT Tag Value. 

Have attached a screenshot and Lisp file for reference.. Thanks...

0 Likes
Accepted solutions (2)
1,804 Views
15 Replies
Replies (15)
Message 2 of 16

dlanorh
Advisor
Advisor

This will create your block with the new constant attribute (Tag Name "IL")

 

(defun crb ( )
  (if (not (tblsearch "BLOCK" "CRBLK"))
      (progn
          (if (not (tblsearch "STYLE" "Isocp"))
              (entmake
                  (list
                      (cons 0 "STYLE")
                      (cons 100 "AcDbSymbolTableRecord")
                      (cons 100 "AcDbTextStyleTableRecord")
                      (cons 2 "Isocp")
                      (cons 70 0)
                      (cons 40 2.5)
                      (cons 3 "Isocp.ttf")
                  )
              )
          )
          (entmake
              (list
                  (cons 0 "BLOCK")
                  (cons 8 "0")
                  (cons 370 0)
                  (cons 2 "CRBLK")
                  (cons 70 2)
                  (cons 4 "Block to Place Coordinate Points")
                  (list 10 0.0 0.0 0.0)
              )
          )
          (entmake
              (list
                  (cons 0 "CIRCLE")
                  (cons 8 "0")
                  (cons 370 0)
                  (list 10 0.0 0.0 0.0)
                  (cons 40 1.25)
              )
          )
          (entmake
              (list
                  (cons 0 "ATTDEF")
                  (cons 8 "0")
                  (cons 370 0)
                  (cons 7 "Isocp")
                  (list 10 3.0 2.5 0.0)
                  (list 11 3.0 2.5 0.0)
                  (cons 40 2.5)
                  (cons 1 "00")
                  (cons 3 "Coordinate Point")
                  (cons 2 "00")
                  (cons 70 0)
                  (cons 72 0)
                  (cons 74 2)
              )
          )
          (entmake
              (list
                  (cons 0 "ATTDEF")
                  (cons 8 "0")
                  (cons 370 0)
                  (cons 7 "Isocp")
                  (list 10 3.0 -2.5 0.0)
                  (list 11 3.0 -2.5 0.0)
                  (cons 40 2.5)
                  (cons 1 "IL=00")
                  (cons 3 "Coordinate Point")
                  (cons 2 "IL")
                  (cons 70 2)
                  (cons 72 0)
                  (cons 74 2)
              )
          )
          (entmake
              (list
                  (cons 0 "ENDBLK")
                  (cons 8 "0")
              )
          )

 ;;;--- To set block units in metre 70-6

         (
             (lambda ( lst )
                 (regapp "ACAD")
                 (entmod
                     (append (subst (cons 70 6) (assoc 70 lst) lst)
                         (list
                            (list -3
                                (list "ACAD"
                                    (cons 1000 "DesignCenter Data")
                                    (cons 1002 "{")
                                    (cons 1070 1)
                                    (cons 1070 1)
                                    (cons 1002 "}")
                                )
                            )
                        )
                     )
                 )
             )
             (entget (cdr (assoc 330 (entget (tblobjname "BLOCK" "CRBLK")))))
         )

;;;--- To make block annotative
         (
              (lambda ( lst )
                  (regapp "ACAD")
                  (regapp "AcadAnnotative")
                  (entmod
                      (append (subst (cons 70 1) (assoc 70 lst) lst)
                          (list
                             (list -3
                                 (list "ACAD"
                                     (cons 1000 "DesignCenter Data")
                                     (cons 1002 "{")
                                     (cons 1070 1)
                                     (cons 1070 1)
                                     (cons 1002 "}")
                                 )
                                 (list "AcadAnnotative"
                                     (cons 1000 "AnnotativeData")
                                     (cons 1002 "{")
                                     (cons 1070 1)
                                     (cons 1070 1)
                                     (cons 1002 "}")
                                 )
                             )
                         )
                      )
                  )
              )
              (entget (cdr (assoc 330 (entget (tblobjname "BLOCK" "CRBLK")))))
          )
      )
  )

;;;--- to disable allow explod-----
  (vl-load-com)
  (setq BLOCKS (vla-get-Blocks (vla-get-activedocument (vlax-get-acad-object)))
        BLK (vla-Item BLOCKS "CRBLK")
  )
  (vla-put-explodable (vla-Item BLOCKS "CRBLK") :vlax-false)

 (princ)
)

I am not one of the robots you're looking for

0 Likes
Message 3 of 16

mint09
Enthusiast
Enthusiast

Its making the attribute in block but i cannot enter the value later, its  not showing in attribute editor when i click it. the constant i mean is that will not increase the value as i place the block using CN command.
And also when later i use command "FCRT" its not adding the IL tag value in the output table. Please check the Screenshot ive added above. @dlanorh ..Thank you ...

0 Likes
Message 4 of 16

dlanorh
Advisor
Advisor

It is a part solution to your request for a second attribute in the block, and it's a CONSTANT attribute as per your request, so you cannot change it by clicking on it in AutoCAD. It's value is fixed. If you want it to be a normal variable (changeable) attribute, I can change it to that; but you will need to let me know what the "prompt string" should be or you could make it a preset value.

 

Has this new block now broken your code to insert the block and increment the "00" attribute?

 

It will not show up when the FCRT lisp is run as this was written for the old block with ONE attribute and so it knows nothing about the second attribute. As this code is working with fields, which I am not familiar with, It will take some time to work out what is doing what; and I don't have a lot of spare time at the moment.

 

 

I am not one of the robots you're looking for

0 Likes
Message 5 of 16

mint09
Enthusiast
Enthusiast

i wanted the second attribute to be a normal variable (changeable) attribute. maybe value "IL=00" . which i can edit later by clicking on it in AutoCAD.

0 Likes
Message 6 of 16

Ajilal.Vijayan
Advisor
Advisor

Try with the attached lisp file.

The changes are as shown below.

1.JPG

 

2.JPG

 

3.JPG

 

 
0 Likes
Message 7 of 16

dlanorh
Advisor
Advisor

Updated create block code.

 

This sets the second attribute to "PRESET" which means you won't be prompted for a value when inserting the block, it will go with the preset vale "IL=00". Other than that it will act like a normal attribute.

 

(defun crb ( )
  (if (not (tblsearch "BLOCK" "CRBLK"))
      (progn
          (if (not (tblsearch "STYLE" "Isocp"))
              (entmake
                  (list
                      (cons 0 "STYLE")
                      (cons 100 "AcDbSymbolTableRecord")
                      (cons 100 "AcDbTextStyleTableRecord")
                      (cons 2 "Isocp")
                      (cons 70 0)
                      (cons 40 2.5)
                      (cons 3 "Isocp.ttf")
                  )
              )
          )
          (entmake
              (list
                  (cons 0 "BLOCK")
                  (cons 8 "0")
                  (cons 370 0)
                  (cons 2 "CRBLK")
                  (cons 70 2)
                  (cons 4 "Block to Place Coordinate Points")
                  (list 10 0.0 0.0 0.0)
              )
          )
          (entmake
              (list
                  (cons 0 "CIRCLE")
                  (cons 8 "0")
                  (cons 370 0)
                  (list 10 0.0 0.0 0.0)
                  (cons 40 1.25)
              )
          )
          (entmake
              (list
                  (cons 0 "ATTDEF")
                  (cons 8 "0")
                  (cons 370 0)
                  (cons 7 "Isocp")
                  (list 10 3.0 2.5 0.0)
                  (list 11 3.0 2.5 0.0)
                  (cons 40 2.5)
                  (cons 1 "00")
                  (cons 3 "Coordinate Point")
                  (cons 2 "00")
                  (cons 70 0)
                  (cons 72 0)
                  (cons 74 2)
              )
          )
          (entmake
              (list
                  (cons 0 "ATTDEF")
                  (cons 8 "0")
                  (cons 370 0)
                  (cons 7 "Isocp")
                  (list 10 3.0 -2.5 0.0)
                  (list 11 3.0 -2.5 0.0)
                  (cons 40 2.5)
                  (cons 1 "IL=00")
                  (cons 3 "IL ?")
                  (cons 2 "IL")
                  (cons 70 8)
                  (cons 72 0)
                  (cons 74 2)
              )
          )
          (entmake
              (list
                  (cons 0 "ENDBLK")
                  (cons 8 "0")
              )
          )

 ;;;--- To set block units in metre 70-6

         (
             (lambda ( lst )
                 (regapp "ACAD")
                 (entmod
                     (append (subst (cons 70 6) (assoc 70 lst) lst)
                         (list
                            (list -3
                                (list "ACAD"
                                    (cons 1000 "DesignCenter Data")
                                    (cons 1002 "{")
                                    (cons 1070 1)
                                    (cons 1070 1)
                                    (cons 1002 "}")
                                )
                            )
                        )
                     )
                 )
             )
             (entget (cdr (assoc 330 (entget (tblobjname "BLOCK" "CRBLK")))))
         )

;;;--- To make block annotative
         (
              (lambda ( lst )
                  (regapp "ACAD")
                  (regapp "AcadAnnotative")
                  (entmod
                      (append (subst (cons 70 1) (assoc 70 lst) lst)
                          (list
                             (list -3
                                 (list "ACAD"
                                     (cons 1000 "DesignCenter Data")
                                     (cons 1002 "{")
                                     (cons 1070 1)
                                     (cons 1070 1)
                                     (cons 1002 "}")
                                 )
                                 (list "AcadAnnotative"
                                     (cons 1000 "AnnotativeData")
                                     (cons 1002 "{")
                                     (cons 1070 1)
                                     (cons 1070 1)
                                     (cons 1002 "}")
                                 )
                             )
                         )
                      )
                  )
              )
              (entget (cdr (assoc 330 (entget (tblobjname "BLOCK" "CRBLK")))))
          )
      )
  )

;;;--- to disable allow explod-----
  (vl-load-com)
  (setq BLOCKS (vla-get-Blocks (vla-get-activedocument (vlax-get-acad-object)))
        BLK (vla-Item BLOCKS "CRBLK")
  )
  (vla-put-explodable (vla-Item BLOCKS "CRBLK") :vlax-false)

 (princ)
)

Do you have a table style set up for this?

 

If Yes, please upload a sample drawing (saved in AutoCAD 2010 format) containing the tablestyle.

 

If No, we will have to create a simple one. This will make inserting the table(s) far easier and should enable all the tables (if more than one) to be set out in a grid given the top left insertion point of the first table.

 

 

I am not one of the robots you're looking for

0 Likes
Message 8 of 16

dlanorh
Advisor
Advisor

Attached is updated Lisp.I have removed all the superfluous code, updated the make block routine and moved various sub routines about. Checks for text styles, layers etc are moved into the relevant functions.

 

There is now one lisp "CN" to insert primary numbers or sub numbers. You are asked which for each run of the lisp.

 

FCRT now updated to work with the new block and to produce a series of tables depending on how many items selected. The tables will be arranged in a grid 5 tables wide by however many deep, starting from the top left across and then down. A single choice inserts a single table. Tables are inserted onto layer "BEND AND T NUMBERS"

 

I am not one of the robots you're looking for

0 Likes
Message 9 of 16

mint09
Enthusiast
Enthusiast

i think there is some problem with lisp. its not adding any block after i use CN . just a circle at 0,0. Don't know whats the problem. i checked this in a new drawing.  @dlanorh 

0 Likes
Message 10 of 16

mint09
Enthusiast
Enthusiast

its adding the attributes and all functions for CN command but when i use the FCRT command its not giving me the IL value in the table like the 00 tag values are given. Its all giving IL=00 in the table. wanted the IL tag value in it.
@Ajilal.Vijayan . 
@dlanorh  the final lisp you added was giving me some bad argument problems.. dont know why
thanks for the helps.... looking forward for some solutions if possible...

0 Likes
Message 11 of 16

Ajilal.Vijayan
Advisor
Advisor
Accepted solution

Please find the updated lisp file.

Message 12 of 16

dlanorh
Advisor
Advisor

Attached is updated lisp. There was a problem in the create block code that didn't show up in the test drawing but did in a new drawing.

 

Also attached is the test drawing

I am not one of the robots you're looking for

Message 13 of 16

mint09
Enthusiast
Enthusiast

this is now creating new blocks and all for the CN command but when i used the FCRT command, it gives me this error
"Oops an Error : bad argument type: VLA-OBJECT nil occurred."  
i dont know why, but the CN command and blocks are working good. thanks man @dlanorh 

@Ajilal.Vijayan  the lisp you added is working as i wanted, thank you so much.. it gonna help me a lot in my work. i have to make tables for almost 1500+ bends and tees. this will make it easier.
Both of you lisp codes are totally different and its amazing
Thank you both for the helps. Really appreciate it.... @Ajilal.Vijayan @dlanorh 

0 Likes
Message 14 of 16

Ajilal.Vijayan
Advisor
Advisor

You're welcome.Glad I could help.

Message 15 of 16

dlanorh
Advisor
Advisor
Accepted solution

OK. A spelling mistake in a variable name. Attached is update lisp. I've also tweaked the table routine as this wasn't correct in a new drawing.

 

I am not one of the robots you're looking for

Message 16 of 16

dlanorh
Advisor
Advisor

I have changed the font file in the above, as the font in the original was not available on my system. It should be reset to "isocp.ttf" in both C:CN and C:FCRT before running either lisp in a new drawing otherwise it will default to "romans.shx".

I am not one of the robots you're looking for