See the top rated post in this thread. Click here

Results 1 to 6 of 6

Thread: help! lisp to change flip state of inserted dynamic block

  1. #1
    Login to Give a bone
    0

    Question help! lisp to change flip state of inserted dynamic block

    Hi all,

    I'm working on a routine to insert dynamic blocks, and then change the flip state of the block from "not-flipped" to "flipped" however, I'm not grasping the information that I'm finding on the web about how to do it. If someone could look at this code and tell me (like I'm in kindergarten) where I'm going wrong, that would be great. The block gets inserted just fine, but then nothing else appears to be happening. Yes, I plagiarized most of this from Lee Mac... Thanks, Lee!
    Code:
    (defun c:test ( / obj ); 
    	(setq pt1 (getpoint "\nSelect insert location:\n"))			
    	(command "insert" "30F" pt1 "" "" "");30F is name of dynamic block
        	(if (and (setq obj (entlast))
                	(= "AcDbBlockReference" (vla-get-objectname (setq obj (vlax-ename->vla-object obj))))
                 	(= :vlax-true (vla-get-isdynamicblock obj))
            )
            (LM:setdynpropvalue obj "hrflip" 1)
        )
        (princ)
    )
    
    (defun LM:setdynpropvalue ( blk prp val ); 
    	(setq prp (strcase prp))
        	(vl-some
           '(lambda ( x )
                (if (= prp (strcase (vla-get-propertyname x)))
                    (progn
                        (vla-put-value x (vlax-make-variant val (vlax-variant-type (vla-get-value x))))
                        (cond (val) (t))
                    )
                )
            )
            (vlax-invoke blk 'getdynamicblockproperties)
        )
    )
    (vl-load-com)
     (princ)
    Last edited by BlackBox; 2019-08-14 at 01:32 PM. Reason: Please use [CODE] Tags

  2. #2
    Member
    Join Date
    2018-06
    Posts
    5
    Login to Give a bone
    1

    Default Re: help! lisp to change flip state of inserted dynamic block

    First check to see if "hrflip" is the actual property you have to set. Generally it would be "Visibility1" unless you changed it. Secondly, I would use a string "1" and not an integer 1. Third, I would verify that "1" is an option on your drop down menu in the properties palette. It should match one of those options.

  3. #3
    Login to Give a bone
    0

    Default Re: help! lisp to change flip state of inserted dynamic block

    Quote Originally Posted by ACE769734 View Post
    First check to see if "hrflip" is the actual property you have to set. Generally it would be "Visibility1" unless you changed it. Secondly, I would use a string "1" and not an integer 1. Third, I would verify that "1" is an option on your drop down menu in the properties palette. It should match one of those options.
    I think you're on to something here, Ace. It still isnt working, but at least I'm getting a message now. I changed this line: (LM:setdynpropvalue obj "Flip" "Flipped") where if I'm understanding correctly, "Flip" is the name and "Flipped" or "Not Flipped" are the two visibility options, of which i want to select "Flipped". I think this is what you were saying to do. Anyway, now I'm getting this message: error: lisp value has no coercion to VARIANT with this type: "Flipped"

  4. #4
    All AUGI, all the time Tharwat's Avatar
    Join Date
    2010-06
    Posts
    899
    Login to Give a bone
    1

    Default Re: help! lisp to change flip state of inserted dynamic block

    Hi,
    Give this a shot and let me know.
    Code:
    (defun c:test (/ pt1 obj props)
      (if (setq pt1 (getpoint "\nSelect insert location:\n"))
        (progn
          (command "insert" "30F" pt1 "" "" "")
          (and (setq obj (entlast))
               (= "AcDbBlockReference" (vla-get-objectname (setq obj (vlax-ename->vla-object obj))))
               (= :vlax-true (vla-get-isdynamicblock obj))
               (setq props (vlax-invoke obj 'getdynamicblockproperties))
               (foreach prop props
                 (if (eq "hrflip" (vla-get-propertyname prop))
                   (vla-put-value prop (vlax-make-variant 1 2))
                   )
                 )
               )
          )
        )
      (princ)
    ) (vl-load-com)

  5. #5
    Login to Give a bone
    0

    Default Re: help! lisp to change flip state of inserted dynamic block

    Quote Originally Posted by Tharwat View Post
    Hi,
    Give this a shot and let me know.
    Code:
    (defun c:test (/ pt1 obj props)
      (if (setq pt1 (getpoint "\nSelect insert location:\n"))
        (progn
          (command "insert" "30F" pt1 "" "" "")
          (and (setq obj (entlast))
               (= "AcDbBlockReference" (vla-get-objectname (setq obj (vlax-ename->vla-object obj))))
               (= :vlax-true (vla-get-isdynamicblock obj))
               (setq props (vlax-invoke obj 'getdynamicblockproperties))
               (foreach prop props
                 (if (eq "hrflip" (vla-get-propertyname prop))
                   (vla-put-value prop (vlax-make-variant 1 2))
                   )
                 )
               )
          )
        )
      (princ)
    ) (vl-load-com)
    EUREKA! That did the trick, Tharwat! Thank you!

  6. #6
    All AUGI, all the time Tharwat's Avatar
    Join Date
    2010-06
    Posts
    899
    Login to Give a bone
    0

    Default Re: help! lisp to change flip state of inserted dynamic block

    Quote Originally Posted by aaronashley1977783620 View Post
    EUREKA! That did the trick, Tharwat! Thank you!
    You're welcome anytime.

Similar Threads

  1. 2016: Dynamic Block Visiblity State Won't Go back to Initial State
    By jkollars in forum Dynamic Blocks - Technical
    Replies: 4
    Last Post: 2015-12-04, 07:23 PM
  2. Replies: 2
    Last Post: 2013-06-04, 02:59 AM
  3. 2011: Use a Flip State to Control Another Flip State
    By stusic in forum Dynamic Blocks - Technical
    Replies: 7
    Last Post: 2013-02-08, 05:16 PM
  4. Lock visibility state once Dynamic Block has been inserted
    By clarkrj in forum Dynamic Blocks - Technical
    Replies: 1
    Last Post: 2006-05-04, 01:24 PM
  5. Replies: 6
    Last Post: 2006-04-07, 01:41 PM

Posting Permissions

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