See the top rated post in this thread. Click here

Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21

Thread: extract linear parameter length from dynamic block

  1. #11
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    1

    Default Re: extract linear parameter length from dynamic block

    I have completed the codes for you but you need to modify it to suit your needs since that I don't know what you are trying to do with the return value from the LENGTH attribute besides that the alert message which is not logic in this case I believe.

    So just ask if you stuck.

    NOTE: I could not open your drawing since it's saved in later release than mine CAD 2017.
    Code:
    (defun c:penrodcount (/ blks num blk effname unsup)
      (if (setq blks (ssget (list (cons 0 "insert") (cons 2 "`*U*,Pencil Rod") (cons 8 "TIE - Pencil Rod"))))
        (progn                                         
          (repeat (setq num (sslength blks))
            (setq blk (vlax-ename->vla-object (ssname blks (setq num (1- num)))))
            (setq effname (vla-get-EffectiveName blk))
            (cond ((= effname "Pencil Rod") (Get:param:value blk)) ;; you need to assign the value to a variable to use it elsewhere you like in the codes.
                  (t (setq unsup effname)) 
            )                       
          )                       
        )                         
      )                           
      (if unsup (alert (strcat "Unsupported block  " unsup "  found in count process")))
      (princ)
      )
    
    (vl-load-com)
    
    (defun Get:param:value (blk / val)
      ;; blk = Block reference vla-object.	;;
      (vl-some '(lambda (x)
                  (and (= (strcase (vla-get-propertyname x)) "LENGTH")
                       (setq val (vlax-get x 'Value))
                  )
                )
               (vlax-invoke blk 'getdynamicBlockproperties)
      )
      val
    )

  2. #12
    Login to Give a bone
    0

    Default Re: extract linear parameter length from dynamic block

    Quote Originally Posted by Tharwat View Post
    I have completed the codes for you but you need to modify it to suit your needs since that I don't know what you are trying to do with the return value from the LENGTH attribute besides that the alert message which is not logic in this case I believe.

    So just ask if you stuck.

    NOTE: I could not open your drawing since it's saved in later release than mine CAD 2017.
    Code:
    (defun c:penrodcount (/ blks num blk effname unsup)
      (if (setq blks (ssget (list (cons 0 "insert") (cons 2 "`*U*,Pencil Rod") (cons 8 "TIE - Pencil Rod"))))
        (progn                                         
          (repeat (setq num (sslength blks))
            (setq blk (vlax-ename->vla-object (ssname blks (setq num (1- num)))))
            (setq effname (vla-get-EffectiveName blk))
            (cond ((= effname "Pencil Rod") (Get:param:value blk)) ;; you need to assign the value to a variable to use it elsewhere you like in the codes.
                  (t (setq unsup effname)) 
            )                       
          )                       
        )                         
      )                           
      (if unsup (alert (strcat "Unsupported block  " unsup "  found in count process")))
      (princ)
      )
    
    (vl-load-com)
    
    (defun Get:param:value (blk / val)
      ;; blk = Block reference vla-object.	;;
      (vl-some '(lambda (x)
                  (and (= (strcase (vla-get-propertyname x)) "LENGTH")
                       (setq val (vlax-get x 'Value))
                  )
                )
               (vlax-invoke blk 'getdynamicBlockproperties)
      )
      val
    )
    Thanks, Tharwat! I am getting a result from your code, so I think i can integrate that into what I'm doing. If I get stuck, I'll be back. Thanks again! Cheers, -Aaron

  3. #13
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: extract linear parameter length from dynamic block

    Quote Originally Posted by aaronashley1977783620 View Post
    Thanks, Tharwat! I am getting a result from your code, so I think i can integrate that into what I'm doing. If I get stuck, I'll be back. Thanks again! Cheers, -Aaron
    You're welcome anytime Aaron.

    Feel free to ask whenever you need any further help.

    Have a nice day.

  4. #14
    Woo! Hoo! my 1st post
    Join Date
    2020-01
    Posts
    1
    Login to Give a bone
    0

    Default Re: extract linear parameter length from dynamic block

    Quote Originally Posted by aaronashley1977783620 View Post
    ok, I made that change, and now it says ; error: too many arguments
    try this


    Code:
    (defun pen-rod-count ( / blks val i)
      (setq blks (ssget "X" (list (cons 0 "insert") (cons 8 "TIE - Pencil Rod"))))
      (setq i 0)
    
      (repeat (sslength blks)
        (if
          (setq val (get:param:value (vlax-ename->vla-object (ssname blks i))))
          (princ (strcat "\n" (rtos val 4 2)))) ;end if
    
      (setq i (+ i 1)))) ;end defun
    I used ssget "X" for testing purpose only

  5. #15
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: extract linear parameter length from dynamic block

    Quote Originally Posted by developer787622 View Post
    try this

    I used ssget "X" for testing purpose only
    Hi,
    If the ssget returned nil then your routine would end with an error.

  6. #16
    Login to Give a bone
    0

    Default Re: extract linear parameter length from dynamic block

    I was successful in creating a program that fulfilled its purpose! Thanks again Tharwat! But, now I have another program that is trying to do something related, but different. Instead of getting the Length value of a dynamic block, I'm trying to SET the value. I want to insert the dynamic block, and then (setq obj (entlast)) and somehow set the length property of the object to a pre-determined length.

  7. #17
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: extract linear parameter length from dynamic block

    Hi,
    Is your dynamic block attributed ? and what is the name of your block ?

  8. #18
    Login to Give a bone
    0

    Default Re: extract linear parameter length from dynamic block

    Quote Originally Posted by Tharwat View Post
    Hi,
    Is your dynamic block attributed ? and what is the name of your block ?
    This particular block doesn't have attributes. The name of the block is "15mm DWYIDAG Rod" I've attached a screenshot for clarity. Thanks!

    dywidag.png

  9. #19
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: extract linear parameter length from dynamic block

    Here is an example for you to move on with your program.

    Code:
    (defun c:Test (/ ins blk)
      (if
        (and
          (or
    	(tblsearch "BLOCK" "15mm DWYIDAG Rod")
    	(alert
    	  "Block name <15mm DWYIDAG Rod> wasn't found in this drawing <!>"
    	)
          )
          (setq ins (getpoint "\nSpecify insertion point : "))
          (setq blk	(entmakex (list	'(0 . "INSERT")
    				(cons 10 ins)
    				(cons 2 "15mm DWYIDAG Rod")
    				'(41 . 1.0)
    				'(42 . 1.0)
    				'(43 . 1.0)
    			  )
    		)
          )
        )
         (Set:param:value (vlax-ename->vla-object blk) 10.0) 
      )
      (princ)
    )
    
    (vl-load-com)
    
    (defun Set:param:value (blk len / val)
      ;; blk = Block reference vla-object.	;;
      ;; len = Length value.		;;
      (vl-some '(lambda (x)
    	      (and (= (strcase (vla-get-propertyname x)) "LENGTH")
    		   (progn (vlax-put x 'Value len) t)
    	      )
    	    )
    	   (vlax-invoke blk 'getdynamicBlockproperties)
      )
    )

  10. #20
    Login to Give a bone
    0

    Default Re: extract linear parameter length from dynamic block

    Thanks Tharwat, I'll let you know if I run into problems!

Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. 2011: Varying increment value for linear parameter for dynamic block
    By Sam Spade in forum Dynamic Blocks - Technical
    Replies: 4
    Last Post: 2013-02-07, 05:35 PM
  2. Linear Parameters vs. Linear Dimensional Constraint
    By melissa_r_alexander in forum Dynamic Blocks - Technical
    Replies: 1
    Last Post: 2010-07-09, 05:10 PM
  3. one linear parameter moves another's parameter grip
    By Coolmo in forum Dynamic Blocks - Technical
    Replies: 4
    Last Post: 2008-04-28, 01:26 PM
  4. Extract Dynamic Block Attributes, values change as Block changes
    By dave.buckberry in forum Dynamic Blocks - Technical
    Replies: 11
    Last Post: 2006-09-05, 04:38 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
  •