See the top rated post in this thread. Click here

Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: extract linear parameter length from dynamic block

  1. #1
    Login to Give a bone
    0

    Default extract linear parameter length from dynamic block

    Hi, I've got a dynamic block that has a linear parameter with a distance name called "Length" that I'm trying to extract the value. How would I go about doing that in lisp? Thanks in advance! -Aaron

  2. #2
    Active Member
    Join Date
    2015-12
    Location
    Western Europe
    Posts
    57
    Login to Give a bone
    0

    Default Re: extract linear parameter length from dynamic block

    Take a look HERE ==> http://www.lee-mac.com/dynamicblockfunctions.html

    - - - Updated - - -

    Oops http://www.lee-mac.com/dynamicblockfunctions.html

    - - - Updated - - -

    Well that wasn't very successful HERE

    - - - Updated - - -

    Linky Thingy http://www.lee-mac.com/dynamicblockfunctions.html

    - - - Updated - - -

    Quote Originally Posted by dlanor View Post
    Take a look HERE ==> http://www.lee-mac.com/dynamicblockfunctions.html
    Perhaps This will work
    Last edited by Ed Jobe; 2020-01-07 at 10:51 PM.

  3. #3
    Login to Give a bone
    0

    Default Re: extract linear parameter length from dynamic block

    I've been there, but none of those pieces of code make sense to me how to integrate them into what I'm doing.

  4. #4
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,420
    Login to Give a bone
    0

    Default Re: extract linear parameter length from dynamic block

    If you already have something, post your code.
    C:> ED WORKING....


    LinkedIn

  5. #5
    Active Member
    Join Date
    2015-12
    Location
    Western Europe
    Posts
    57
    Login to Give a bone
    0

    Default Re: extract linear parameter length from dynamic block

    Quote Originally Posted by aaronashley1977783620 View Post
    I've been there, but none of those pieces of code make sense to me how to integrate them into what I'm doing.
    Providing you are using a windows full fat version of AutoCAD, then use this function. Just insert the code above your main lisp function and ensure the (vl-load-com) is there.

    Call it from within your lisp like this (setq val (LM:getdynpropvalue blk prop)), replacing blk and prop with the block and property as required in the red highlighted comments

    Code:
    ;; Get Dynamic Block Property Value  -  Lee Mac
    ;; Returns the value of a Dynamic Block property (if present)
    ;; blk - [vla] VLA Dynamic Block Reference object
    ;; prp - [str] Dynamic Block property name (case-insensitive)
    
    (vl-load-com) 
    
    (defun LM:getdynpropvalue ( blk prp )
        (setq prp (strcase prp))
        (vl-some '(lambda ( x ) (if (= prp (strcase (vla-get-propertyname x))) (vlax-get x 'value)))
            (vlax-invoke blk 'getdynamicblockproperties)
        )
    )

  6. #6
    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,

    Try this function.
    Code:
    (defun Get:param:value (blk / val)
      ;; blk = Block reference vla-object.	;;
      (vl-some '(lambda (x)
                  (and (= (strcase (vla-get-propertyname x)) "LENGTH")
                       (progn (setq val (vlax-get x 'Value)) t)
                  )
                )
               (vlax-invoke blk 'getdynamicBlockproperties)
      )
      val
    ) (vl-load-com)

  7. #7
    Login to Give a bone
    0

    Default Re: extract linear parameter length from dynamic block

    Quote Originally Posted by Ed Jobe View Post
    If you already have something, post your code.
    here's what i have so far

    Code:
    (defun c:penrodcount ( ) ;/ unsup effname num unsupstring
    	(vl-load-com)
    	(setq BB1 (getpoint "\nWindow select areas to be counted:\n"))						;asks 1st point of area
    	(setq BB2 (getcorner BB1))										;asks 2nd point of area
    	(if (setq blks (ssget "w" bb1 bb2 (list (cons 0 "insert") (cons 8 "TIE - Pencil Rod"))))		;selection set of blocks in current bounding box
    		(progn												;start progn
    			(setq num 0)										;set block number to 0, aka first
    			(repeat (sslength blks)									;repeat this the number of blocks found
    				(setq blk (ssname blks num))							;set current block
    				(setq effname (vla-get-EffectiveName (vlax-ename->vla-object blk)))		;gets effective name of current block
    				(cond										;conditional that puts the current entity into the correct selection set based on effective name
    					((= effname "Pencil Rod") (findlength))					;if effective name is Pencil Rod, run findlength subroutine 
    					(t (setq unsup effname))						;if effective name is not, then set unsup name to current block name
    				)										;end of cond
    				(setq num (+ 1 num))								;adds 1 to block number so can go to next block
    			)											;end of repeat
    		)												;end progn
    	)													;end if
    	(if (/= unsup nil)											;if unsup has value
    		(progn												;progn
    		  	(setq unsupstring (strcat "Unsupported block  " unsup "  found in count process"))	;create alert string
    			(alert unsupstring)									;alert
    		)												;end progn
    	)													;end if
    )  														;end 
    
    (defun findlength ( / currentlength)
    	;; (setq currentlength 	??????????????????????????????????				;PART IM ASKING ABOUT
    	;; round to nearest inch								;haven't written yet
    	;; if this size doesnt exist, 								;start of if
    		;; create new size & add this entity to count of current size			;
    		;; add this entity to count of existing size					;
    	;;											;end of if
    )
    I attempted to insert both of the proposed sections of code by Tharwat and dlanor instead of (findlength) and they resulted in an error saying that there were too few arguments. I think part of the problem is that I don't know what I'm supposed to put for "prp" if using code suggested by dlanor, or "val" if using code suggested by Tharwat.

    If I copy (vlax-invoke blk 'getdynamicblockproperties) into the command line after running the program, i get ; error: bad argument type: VLA-OBJECT <Entity name: 163161a1480>

    Don't know if this helps or not, but thank you all for your help.

    If I can figure out how to upload the block i'm working with, i'd be willing to do that if it would help too.

    Thanks again - Aaron
    Last edited by aaronashley1977783620; 2020-01-08 at 03:24 PM.

  8. #8
    Login to Give a bone
    0

    Default Re: extract linear parameter length from dynamic block

    here's the block. I'm trying to retrieve the dimension, in this case, it's set at 8.5 inches.

    Thanks again
    Attached Files Attached Files

  9. #9
    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

    This part.

    Code:
    ((= effname "Pencil Rod") (Get:param:value (vlax-ename->vla-object blk)))

  10. #10
    Login to Give a bone
    0

    Default Re: extract linear parameter length from dynamic block

    Quote Originally Posted by Tharwat View Post
    This part.

    Code:
    ((= effname "Pencil Rod") (Get:param:value (vlax-ename->vla-object blk)))
    ok, I made that change, and now it says ; error: too many arguments

Page 1 of 3 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
  •