+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Senior Member SunnyTurtle's Avatar
    Computer Details
    SunnyTurtle's Computer Details
    Operating System:
    Win 7 64 bit
    Computer:
    HP 600 Workstation
    CPU:
    Intel(R) Xeon(R) CPU X5650 @ 2.67GHz 2.66GHz
    RAM:
    6GB
    Graphics:
    NVIDIA Quadro FX 4800
    Discipline
    Civil
    SunnyTurtle's Discipline Details
    Occupation
    Drafter CAD
    Discipline
    Civil
    Details
    Rail
    Using
    AutoCAD 2014
    Join Date
    Apr 2011
    Location
    Sydney Australia
    Posts
    127

    Default lisp to change visablite state of a dynamic block

    Registered forum members do not see this ad.

    Hi was trying to create a lisp that would change the visablity state of this block if it was inserted into a drawing can anyone help
    Attached Files

  2. #2
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,642

    Default

    Code:
    (defun c:demo (/ ss ans i blk dp)
      	(if 	(and (setq ss (ssget "_:L" '((0 . "INSERT"))))
    		     (not (initget 1 "circle square "))
    	  	     (setq ans (getkword "\nChoose Visibility [circle/square]: ")))
    	       	(repeat (setq i (sslength ss))
    		  	(setq blk (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
    		  	(cond ((and
    				   (eq (vla-get-IsDynamicBlock blk) :vlax-true)
    			       	   (setq dp (car
    					    (vl-remove-if-not
    					      '(lambda (k)
    						 (eq
    						   (vla-get-PropertyName
    						     k
    						   )
    						   "Visibility1"
    						 )
    					       )
    					      (vlax-invoke
    						blk
    						'GetDynamicBlockProperties
    					      )
    					    )
    					  )
    				   )
    			       	(vlax-put dp 'Value ans)
    			        )
    			      ))
    		  )
    	  )
    (princ)
      )
    Last edited by pBe; 22nd Nov 2012 at 03:48 am.

  3. #3
    Senior Member SunnyTurtle's Avatar
    Computer Details
    SunnyTurtle's Computer Details
    Operating System:
    Win 7 64 bit
    Computer:
    HP 600 Workstation
    CPU:
    Intel(R) Xeon(R) CPU X5650 @ 2.67GHz 2.66GHz
    RAM:
    6GB
    Graphics:
    NVIDIA Quadro FX 4800
    Discipline
    Civil
    SunnyTurtle's Discipline Details
    Occupation
    Drafter CAD
    Discipline
    Civil
    Details
    Rail
    Using
    AutoCAD 2014
    Join Date
    Apr 2011
    Location
    Sydney Australia
    Posts
    127

    Default

    Hi im am having problem running the lisp it seems to fail at the line (LAMBDA (K) (EQ (vla-get-PropertyName K) * "Visibility1" *))

    when i run the script i get this error: AutoLISP error - too many arguments

  4. #4
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,642

    Default

    Quote Originally Posted by SunnyTurtle View Post
    Hi im am having problem running the lisp it seems to fail at the line (LAMBDA (K) (EQ (vla-get-PropertyName K) * "Visibility1" *))

    when i run the script i get this error: AutoLISP error - too many arguments
    Not sure where you get that "*" on the lambda function , besides i was missing a pair of parenthesis.

    "Visibility1" is the visibility parameter name on your DBlock. This code wont do a thing if the name does not match.

  5. #5
    Senior Member SunnyTurtle's Avatar
    Computer Details
    SunnyTurtle's Computer Details
    Operating System:
    Win 7 64 bit
    Computer:
    HP 600 Workstation
    CPU:
    Intel(R) Xeon(R) CPU X5650 @ 2.67GHz 2.66GHz
    RAM:
    6GB
    Graphics:
    NVIDIA Quadro FX 4800
    Discipline
    Civil
    SunnyTurtle's Discipline Details
    Occupation
    Drafter CAD
    Discipline
    Civil
    Details
    Rail
    Using
    AutoCAD 2014
    Join Date
    Apr 2011
    Location
    Sydney Australia
    Posts
    127

    Default

    Thanks i remove
    *'s and it worked
    as i just copyed in to visual lisp editor.

    Thankyou so much for your help i was having trouble with a lisp of mine and this code will be easy to modify and add to my lisp
    Last edited by SunnyTurtle; 22nd Nov 2012 at 04:09 am. Reason: more thanks

  6. #6
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,642

    Default

    Quote Originally Posted by SunnyTurtle View Post
    Thanks i remove
    *'s and it worked
    as i just copyed in to visual lisp editor.

    Thankyou so much for your help i was having trouble with a lisp of mine and this code will be easy to modify and add to my lisp
    Good for you, glad it helps

  7. #7
    Senior Member SunnyTurtle's Avatar
    Computer Details
    SunnyTurtle's Computer Details
    Operating System:
    Win 7 64 bit
    Computer:
    HP 600 Workstation
    CPU:
    Intel(R) Xeon(R) CPU X5650 @ 2.67GHz 2.66GHz
    RAM:
    6GB
    Graphics:
    NVIDIA Quadro FX 4800
    Discipline
    Civil
    SunnyTurtle's Discipline Details
    Occupation
    Drafter CAD
    Discipline
    Civil
    Details
    Rail
    Using
    AutoCAD 2014
    Join Date
    Apr 2011
    Location
    Sydney Australia
    Posts
    127

    Default

    Registered forum members do not see this ad.

    I have create a new Thread with a related question

    Here is my code as of today
    Code:
    (defun c:set1 (/ ss ans i blk dp scale)
      
      (if (and (setq ss (ssget "_:L" '((0 . "INSERT"))))
          (not (initget 1 "1:1 1:2 1:2.5 1:5 1:10 1:20 1:25 1:50 1:100 1:200 1:250 1:500 1:1000 1:2000 1:2500 1:5000 1:50000 "))
       (setq ans (getkword "\nChoose Visibility [1:1/1:2/1:2.5/1:5/1:10/1:20/1:25/1:50/1:100/1:200/1:250/1:500/1:1000/1:2000/1:2500/1:5000/1:50000]: ")
        ))
       
      (repeat (setq i (sslength ss))  
         (setq blk (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
         (cond (and
           (eq (vla-get-IsDynamicBlock blk) :vlax-true)
                  (setq dp (car
             (vl-remove-if-not
               '(lambda (k)
           (eq
             (vla-get-PropertyName
               k
             )
             "RMS_SCALE_VIS"
           )
                )
               (vlax-invoke
          blk
          'GetDynamicBlockProperties
               )
             )
           )
           )
              (if (eq ans "1:1") (setq scale "RTA_SCALE_1"))
                     (if (eq ans "1:2") (setq scale "RTA_SCALE_2"))
              (if (eq ans "1:2.5") (setq scale "RTA_SCALE_2.5"))
              (if (eq ans "1:5") (setq scale "RTA_SCALE_5"))
              (if (eq ans "1:10") (setq scale "RTA_SCALE_10"))
              (if (eq ans "1:20") (setq scale "RTA_SCALE_20"))
              (if (eq ans "1:25") (setq scale "RTA_SCALE_25"))
              (if (eq ans "1:50") (setq scale "RTA_SCALE_50"))
              (if (eq ans "1:100") (setq scale "RTA_SCALE_100"))
              (if (eq ans "1:200") (setq scale "RTA_SCALE_200"))
              (if (eq ans "1:500") (setq scale "RTA_SCALE_500"))
              (if (eq ans "1:1000") (setq scale "RTA_SCALE_1000"))
              (if (eq ans "1:2000") (setq scale "RTA_SCALE_2000"))
              (if (eq ans "1:2500") (setq scale "RTA_SCALE_2500"))
              (if (eq ans "1:5000") (setq scale "RTA_SCALE_5000"))
              (if (eq ans "1:50000") (setq scale "RTA_SCALE_50000"))
               (vlax-put dp 'Value scale)
               )
             )
        )
      )
      )
      (princ)

Similar Threads

  1. lisp to change dynamic block visibility
    By woodman78 in forum AutoLISP, Visual LISP & DCL
    Replies: 7
    Last Post: 5th Mar 2013, 12:39 am
  2. Dynamic Block Lost Visibility State
    By Deginault in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 2
    Last Post: 11th Sep 2012, 02:21 pm
  3. Dynamic block visual state
    By Accoes in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 26th May 2011, 04:10 pm
  4. change the visibility list of a dynamic block by lisp
    By alijahed in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 24th May 2010, 01:55 am
  5. Refer to a dynamic block visibility state VBA
    By kyosmith in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 1st Apr 2010, 01:18 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts