Visual LISP, AutoLISP and General Customization

Reply
Contributor
Dewlevlak
Posts: 16
Registered: ‎07-15-2011
Message 11 of 16 (234 Views)

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,

*Expert Elite*
pbejse
Posts: 2,406
Registered: ‎11-24-2009
Message 12 of 16 (227 Views)

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

Contributor
Dewlevlak
Posts: 16
Registered: ‎07-15-2011
Message 13 of 16 (224 Views)

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:

Contributor
Dewlevlak
Posts: 16
Registered: ‎07-15-2011
Message 14 of 16 (176 Views)

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,

 

*Expert Elite*
pbejse
Posts: 2,406
Registered: ‎11-24-2009
Message 15 of 16 (168 Views)

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.

 

 

Contributor
Dewlevlak
Posts: 16
Registered: ‎07-15-2011
Message 16 of 16 (141 Views)

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.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community