See the top rated post in this thread. Click here

Results 1 to 6 of 6

Thread: dynamic block name

  1. #1
    Login to Give a bone
    0

    Default dynamic block name

    Hi to all!

    I made a dynamic block and the block name should be a letter and dimensions of the block.
    The dynamic block has 2 stretch parameters and 2 linear parameters. These parameters allow the user to stretch the polyline to the desired width and height. I’m looking a way to grab the ‘Value’ from each of linear parameters and place those values into the block name if it is possible. If anybody has an idea how...
    After dimensions are set up and name applied it does not has to be a dynamic block if that makes it easier.

    Thanks!

    Denis

  2. #2
    I could stop if I wanted to
    Join Date
    2003-07
    Posts
    467
    Login to Give a bone
    0

    Default Re: dynamic block name

    You can get at dynamic block properties so can do extract data etc no need for individual name, a dynamic block will have a name "U32" but it also has a "Effective name" which is the originally created block.

  3. #3
    Login to Give a bone
    0

    Default Re: dynamic block name

    Thank you for your answer.
    I know that, but it won't work for my needs. I made an attribute that has all information that I need, but a program that I put dwg into recognizes only the name of the block..

  4. #4
    I could stop if I wanted to
    Join Date
    2003-07
    Posts
    467
    Login to Give a bone
    0

    Default Re: dynamic block name

    Get all "U* blocks then do a second pass and look at effective name. Use dumpit.lsp to have a look. or (entget (car (entsel "Pick object" )))

  5. #5
    Login to Give a bone
    0

    Default Re: dynamic block name

    I'll try that.
    Thanks!

  6. #6
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Chelan WA
    Posts
    1,059
    Login to Give a bone
    1

    Default Re: dynamic block name

    Code:
    ;___________________________________________________________________________________________________________|
    ;
    ; Command line function to create a static block from a dynamic block with two distance parameters
    ;___________________________________________________________________________________________________________|
    
    (defun C:StaticBlock (/ entSelection lstProperties objSelection ssSelections strBlockName strEffectiveName)
     (if (and (princ "\nSelect Dynamic Block: ")
              (setq ssSelections     (ssget ":S:E" (list (cons 0 "insert"))))
              (setq entSelection     (ssname ssSelections 0))
              (setq objSelection     (vlax-ename->vla-object entSelection))
              (setq strEffectiveName (vla-get-effectivename objSelection))
              (setq lstProperties    (DynamicPropertiesList objSelection))
              (setq strBlockName     (BlockNewName strEffectiveName lstProperties))
              (not (tblobjname "block" strBlockName))
         )
      (vla-ConvertToStaticBlock objSelection strBlockName)
      (princ "\nError Creating Static Block: ")
     )
     (princ)
    )
    
    ;___________________________________________________________________________________________________________|
    ;
    ; Function to create a new block name from the old dynamic block name and the two distance parameters
    ;___________________________________________________________________________________________________________|
    
    (defun BlockNewName (strEffectiveName lstProperties)
     (strcat strEffectiveName
             "-"
             (vl-princ-to-string (cadr (nth 0 lstProperties)))
             "x"
             (vl-princ-to-string (cadr (nth 1 lstProperties)))
                    
     )
    )
    
    ;___________________________________________________________________________________________________________|
    ;
    ; Function to Get a list of sublists including dynamic block property names and objects.
    ;___________________________________________________________________________________________________________|
    
    (defun DynamicPropertiesList (objDynamicBlock 
                                  / 
                                  lstProperties
                                  X
                                  lstReturn
                                 )
     (if (and(vlax-property-available-p objDynamicBlock "IsDynamicBlock")
              (= (vla-get-IsDynamicBlock objDynamicBlock) :vlax-true)
              (setq lstProperties (vlax-invoke objDynamicBlock "GetDynamicBlockProperties"))
              (setq lstReturn (mapcar '(lambda (x)(list (vlax-get X "propertyname") (vlax-get X "value"))) lstProperties))
         )
      (while (setq lstSublist (assoc "Origin" lstReturn))
       (setq lstReturn (vl-remove lstSublist lstReturn))
      )
     )
     lstReturn
    )
    
    (vl-load-com)
    Attached Files Attached Files
    Last edited by peter; 2021-05-04 at 01:56 PM.
    AutomateCAD

Similar Threads

  1. Replies: 1
    Last Post: 2017-01-15, 12:22 AM
  2. Replies: 0
    Last Post: 2015-03-20, 10:57 AM
  3. Replies: 12
    Last Post: 2010-01-08, 07:49 PM
  4. Dynamic Block in a Dynamic Block
    By jjanis in forum Dynamic Blocks - Technical
    Replies: 1
    Last Post: 2008-06-06, 01:33 PM
  5. Dynamic Block within a dynamic block?
    By pbrumberg in forum Dynamic Blocks - Technical
    Replies: 13
    Last Post: 2006-02-16, 07:05 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
  •