I need to read the 'Dist Minimum' 'Dist Maximum' and 'Dist Increment' from an incremental Linear Parameter

I need to read the 'Dist Minimum' 'Dist Maximum' and 'Dist Increment' from an incremental Linear Parameter

kbrown58JUP
Participant Participant
369 Views
4 Replies
Message 1 of 5

I need to read the 'Dist Minimum' 'Dist Maximum' and 'Dist Increment' from an incremental Linear Parameter

kbrown58JUP
Participant
Participant

I have a dynamic block, basically a rectangle, with a stretch action attached to a linear Parameter called "Width". The parameter is set to operate incrementally.

 

I am writing a function which iterates through each possible "Width" based on information read from a custom config file. Before passing the new value to "Width", I want to verify that it is an acceptable value by comparing it to the 'Dist Minimum', 'Dist Maximum' and 'Dist Increment' values.

 

We can easily find the "Width" parameter with (vlax-invoke <block> 'GetDynamicBlockProperties) and (foreach... through the results until (vla-get-propertyname... matches "Width"; however, I cannot fathom how to read the min, max and increment values for it!

0 Likes
Accepted solutions (1)
370 Views
4 Replies
Replies (4)
Message 3 of 5

Sea-Haven
Mentor
Mentor

Is it not a 3 item list check, maybe like this. Interval min max, a set of rules. Can you provide examples.

 

(3.5 1.5 7.2)

0 Likes
Message 4 of 5

kbrown58JUP
Participant
Participant

I did stumble across those posts, but didn't understand enough to work out how to adjust LM's code to suit my purpose. I've done a fair bit of reading-up over the weekend, so I'm going to take a more educated shot at it...

0 Likes
Message 5 of 5

kbrown58JUP
Participant
Participant
Accepted solution
(defun blockGetLinearParameterProperties (blockVLARef targetParameter / blockEName parameter 
                                          parameterProperties returnList
                                         ) 
  ; Retrieves the distance values for a target linear parameter within a dynamic block
  ; Returns a list: First value is "I" if incremental or "L" if list
  ; If parameter is incremental, three values follow: Minimum, Maximum, Increment
  ; If parameter is list, the allowed list of values follows

  (setq blockEName (vlax-vla-object->ename blockVLARef))

  (if 

    (and 
      (vlax-property-available-p blockEName 'effectivename)
      (setq blockEName (vla-item 
                         (vla-get-blocks (vla-get-document blockEName))
                         (vla-get-effectivename blockEName)
                       ) ; \vla-item
      ) ; \setq
      (= :vlax-true (vla-get-isdynamicblock blockEName))
      (= :vlax-true (vla-get-hasextensiondictionary blockEName))
      (setq parameter (vl-some 

                        '(lambda (pair) 
                           (if 
                             (and 
                               (= 360 (car pair))
                               (= "BLOCKLINEARPARAMETER" (cdr (assoc 0 (entget (cdr pair)))))
                               (= (strcase targetParameter) 
                                  (strcase (cdr (assoc 305 (entget (cdr pair)))))
                               )
                             ) ; \and

                             (cdr pair)
                           ) ; \if
                         ) ; \lambda

                        (dictsearch 
                          (vlax-vla-object->ename (vla-getextensiondictionary blockEName))
                          "ACAD_ENHANCEDBLOCK"
                        ) ; \dictsearch
                      ) ; \vl-some
      ) ; \setq
    ) ; \and

    (progn 
      (setq parameterProperties (entget parameter))

      (if (setq allowedValues (cdr (assoc 144 parameterProperties))) 

        (setq returnList (append (list "L") allowedValues))

        (progn 
          (setq returnList (list "I" 
                                 (cdr (assoc 141 parameterProperties))
                                 (cdr (assoc 142 parameterProperties))
                                 (cdr (assoc 143 parameterProperties))
                           ) ; \list
          ) ; \setq
        ) ; \progn
      ) ; \if
    ) ; \progn
  ) ; \if

  returnList
) ; \defun
0 Likes