• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Visual LISP, AutoLISP and General Customization

    Reply
    Contributor
    Dewlevlak
    Posts: 16
    Registered: ‎07-15-2011

    Re: Insert Dynamic Block programmatically

    06-12-2012 07:57 AM in reply to: kbeake

    Thank you for your quick reply.  I am trying it without success.  Here is a sample file with a simple line block which has a length paramerter 'TheLength'.  I would like to be able to change all of these lengths with LISP all at once. Then, I can train a Button to automatically change all these parameters in the drawing.  I am able to change the lenth of one block selection at a time with (setq obj (car (entsel))). 

     

    Thanks again,

    Please use plain text.
    *Expert Elite*
    Posts: 2,070
    Registered: ‎11-24-2009

    Re: Insert Dynamic Block programmatically

    06-12-2012 08:40 AM in reply to: Dewlevlak

    Dewlevlak wrote:

    Thank you for your quick reply.  I am trying it without success.  Here is a sample file with a simple line block which has a length paramerter 'TheLength'.  I would like to be able to change all of these lengths with LISP all at once. Then, I can train a Button to automatically change all these parameters in the drawing.  I am able to change the lenth of one block selection at a time with (setq obj (car (entsel))). 

     

    Thanks again,


    Guess i need to put it together for you then.

     

    (defun c:chpname  ( / ChangePropertyLength  objs ename)
     (vl-load-com)     
     ;;; Generic sub for property name  ;;;
     (defun ChangePropertyLength  (ent pnme len / props name)
          (setq props (vlax-invoke ent 'getdynamicblockproperties))
          (foreach  prop  props
                (if
                      (eq (strcase (vla-get-propertyname prop)) (strcase pnme))
                           (vla-put-value prop len)
                           )
                )
          )
      (if (and
     (setq TheLength
               (cond  ((getdist
                            (strcat "\nEnter Length <"
                                    (rtos (setq TheLength
                                                     (cond (TheLength) (1.00))
                                                ) 2 2 )  ">: " )))
                     (TheLength)))
                (setq objs (ssget ":L" '((0 . "INSERT")))))
            (repeat (setq i (sslength objs))
                  (setq ename (vlax-ename->vla-object
                                    (ssname objs
                                            (setq i (1- i)))))
                  (ChangePropertyLength
                        ename  "TheLength" TheLength))
          )
      )

     

    There are many ways to write this code, but i opted not to deviate from the orignal.

     

    HTH

    Please use plain text.
    Contributor
    Dewlevlak
    Posts: 16
    Registered: ‎07-15-2011

    Re: Insert Dynamic Block programmatically

    06-12-2012 09:05 AM in reply to: Dewlevlak

    :smileyhappy Oh Sweet!  That is so AWESOME!  Thank you!  Thank you! Thank you!  That works great! 

    I will go through it to try to understand how it all works.  But it does work in the drawings the way I needed it to! :smileyvery-happy:

    Please use plain text.
    Contributor
    Dewlevlak
    Posts: 16
    Registered: ‎07-15-2011

    Re: Insert Dynamic Block programmatically

    09-14-2012 01:04 PM in reply to: pbejse

    Hello again

    Thank you, your help has been very  helpful.  I have been able to modify and use your program to modify all parameters of blocks in the drawing for different purposes.  I have come across another situation to which I need help.

     

    I would like to change the "Visibility" of blocks nested in another block.  I have a block in the drawing which has 3 blocks nested in it.  How do I selet the nested blocks within a particular block to be changed?   

     

    Thanks again,

     

    Please use plain text.
    *Expert Elite*
    Posts: 2,070
    Registered: ‎11-24-2009

    Re: Insert Dynamic Block programmatically

    09-14-2012 04:59 PM in reply to: Dewlevlak

    Dewlevlak wrote:

     

    I would like to change the "Visibility" of blocks nested in another block.  I have a block in the drawing which has 3 blocks nested in it.  How do I selet the nested blocks within a particular block to be changed?   

     

    Thanks again,

     


    As it affect every instance of the block in the drawing might as well Bedit or Refedit the block then run the code there.

     

     

    Please use plain text.
    Contributor
    Dewlevlak
    Posts: 16
    Registered: ‎07-15-2011

    Re: Insert Dynamic Block programmatically

    09-18-2012 12:49 PM in reply to: pbejse

    Thank you, that worked slick. Sometimes it is easy when programing to forget the simple used all the time AutoCAD commands.

    Please use plain text.