Jump to content

Set Dynamic Block Property Value Ang value list Allowed Values


Recommended Posts

Posted

I would like to set to my dynamic block "LS" allowed Property Values - "Ang value list".

 

I've tried Mac Lee Set Dynamic Block Property Value https://lee-mac.com/dynamicblockfunctions.html but unfortunatelly I can't set the "Ang value list".

 

"Angle1" and "Angle2" is the name of properties.

 

Maybe someone has already a modyfied version of Mac Lee script to set "Ang value list"?

 

Best regards

Marcin

ang-value-list.PNG

LS.dwg

Posted

Can you elaborate? Do you want an action that only rotates to one of the angles on your list? Do you want attributes that can only have certain values? or something else? What do you mean by "ang value list"?

Posted

"Ang value list" is a list of allowed angles for polar parameter. So by clicking on grip there are only a certain angles to choose from.

 

I need to set that list of angles. It will be rather long list (200 or more values)

 

In dwg file I set already some values in list for "Angle2" parameter

 

 

list-angle-list.PNG

Posted

Ok so load "lee-mac Dynamic block.lsp" then (LM:setdynpropvalue obj "Angle2" 237) it works, ok so you say you have lots of angles that you want to pick from, where is this angle coming from ?

 

Yes can do a list box of lots of angles and choose then your block can be updated. Can have also say "newvalue". Post a txt file of angles may be able to do something. One angle per line.

 

Same with insert block, choose angles, then angle dimension.

Posted

Hello BIGAL,

 

I posted txt file with angles (rad). Angles are the result of another LISP function which I also post below.

 

I would like to solve first problem how to set "new values" to the "ang value list".

 

(defun c:sun-azimuth-array ( / lat lon year month day jd jc gmst lst ha decl azimuth time-list)
  ;; Utility functions
  (defun deg-to-rad (deg) (* pi (/ deg 180.0)))
  (defun rad-to-deg (rad) (* 180.0 (/ rad pi)))
  (defun mod (a b) (- a (* b (fix (/ a b)))))
  
  ;; Inverse sine function
  (defun asin (x)
    (atan (/ x (sqrt (- 1 (* x x)))))
  )

  ;; Tangent function
  (defun tan (x)
    (/ (sin x) (cos x))
  )

  ;; Function to calculate Julian Date
  (defun julian-date (year month day hour minute second)
    (setq a (fix (/ (- 14 month) 12)))
    (setq y (+ year 4800 a))
    (setq m (+ month (* 12 a) -3))
    (+ day
       (/ (- (* 153 (+ m 1)) 2) 5)
       (* 365 y)
       (/ y 4)
       (/ (- y 100) 100)
       (/ y -400)
       -32045
       (/ (+ hour (/ minute 60.0) (/ second 3600.0)) 24.0)
    )
  )

  ;; Function to calculate Sun Azimuth
  (defun sun-azimuth (lat lon jd)
    ;; Calculate Julian Century
    (setq jc (/ (- jd 2451545.0) 36525.0))

    ;; Calculate Greenwich Mean Sidereal Time
    (setq gmst (mod (+ 280.46061837 (* 360.98564736629 (- jd 2451545.0)) (* 0.000387933 (* jc jc)) (/ (* jc jc jc) -38710000.0)) 360.0))

    ;; Local Sidereal Time
    (setq lst (mod (+ gmst (rad-to-deg lon)) 360.0))

    ;; Calculate Mean Anomaly of the Sun
    (setq m (mod (+ 357.5291 (* 35999.0503 jc)) 360.0))

    ;; Calculate Mean Longitude of the Sun
    (setq l0 (mod (+ 280.46646 (* 36000.76983 jc) (* 0.0003032 (* jc jc))) 360.0))

    ;; Calculate Ecliptic Longitude of the Sun
    (setq c (+ (* (sin (deg-to-rad m)) 1.914602) (* (sin (deg-to-rad (* 2 m))) 0.019993) (* (sin (deg-to-rad (* 3 m))) 0.000289)))
    (setq lambda (+ l0 c))

    ;; Calculate Declination of the Sun
    (setq eps (deg-to-rad (+ 23.439 (- (* 0.00000036 jc)))))
    (setq decl (asin (* (sin eps) (sin (deg-to-rad lambda)))))

    ;; Calculate Hour Angle
    (setq ha (- lst (rad-to-deg lambda)))

    ;; Convert Hour Angle and Latitude to Radians
    (setq ha (deg-to-rad ha))

    ;; Calculate Azimuth in Radians
    (setq azimuth (atan (/ (sin ha) (- (* (cos ha) (sin lat)) (* (tan decl) (cos lat))))))

    azimuth
  )

  ;; User inputs
  (setq lat (deg-to-rad (getreal "\nEnter latitude: ")))
  (setq lon (deg-to-rad (getreal "\nEnter longitude: ")))
  (setq year (getint "\nEnter year: "))
  (setq month (getint "\nEnter month: "))
  (setq day (getint "\nEnter day: "))

  ;; Initialize the list
  (setq time-list '())

  ;; Loop through each minute from 6:00 to 18:00
  (setq hour 6)
  (while (<= hour 18)
    (setq minute 0)
    (while (< minute 60)
      ;; Calculate Julian Date for the current time
      (setq jd (julian-date year month day hour minute 0))
      
      ;; Calculate Sun Azimuth
      (setq azimuth (sun-azimuth lat lon jd))
      
      ;; Create the time string and append to the list
      (setq time-str (strcat (itoa hour) ":" (if (< minute 10) (strcat "0" (itoa minute)) (itoa minute))))
      (setq time-list (append time-list (list (strcat time-str " " (rtos azimuth 2 6)))))
      
      ;; Increment minute
      (setq minute (+ minute 1))
    )
    ;; Increment hour
    (setq hour (+ hour 1))
  )

  ;; Print the list of time and azimuth values
  (foreach item time-list
    (prompt (strcat "\n" item))
  )

  (princ)
)

 

 

list of angles.txt

Posted (edited)

Try this, but you will have to remove the lookup values for the angles. Save the multi getvals into a support path as it auto loads.

 

; (defun c:sun-azimuth-array ( / lat lon year month day jd jc gmst lst ha decl azimuth time-list)

 (defun c:sun-azimuth-array ( /)
  ;; Utility functions
  (defun deg-to-rad (deg) (* pi (/ deg 180.0)))
  (defun rad-to-deg (rad) (* 180.0 (/ rad pi)))
  (defun mod (a b) (- a (* b (fix (/ a b)))))
  
  ;; Inverse sine function
  (defun asin (x)
    (atan (/ x (sqrt (- 1 (* x x)))))
  )

  ;; Tangent function
  (defun tan (x)
    (/ (sin x) (cos x))
  )

  ;; Function to calculate Julian Date
  (defun julian-date (year month day hour minute second)
    (setq a (fix (/ (- 14 month) 12)))
    (setq y (+ year 4800 a))
    (setq m (+ month (* 12 a) -3))
    (+ day
       (/ (- (* 153 (+ m 1)) 2) 5)
       (* 365 y)
       (/ y 4)
       (/ (- y 100) 100)
       (/ y -400)
       -32045
       (/ (+ hour (/ minute 60.0) (/ second 3600.0)) 24.0)
    )
  )

  ;; Function to calculate Sun Azimuth
  (defun sun-azimuth (lat lon jd)
    ;; Calculate Julian Century
    (setq jc (/ (- jd 2451545.0) 36525.0))

    ;; Calculate Greenwich Mean Sidereal Time
    (setq gmst (mod (+ 280.46061837 (* 360.98564736629 (- jd 2451545.0)) (* 0.000387933 (* jc jc)) (/ (* jc jc jc) -38710000.0)) 360.0))

    ;; Local Sidereal Time
    (setq lst (mod (+ gmst (rad-to-deg lon)) 360.0))

    ;; Calculate Mean Anomaly of the Sun
    (setq m (mod (+ 357.5291 (* 35999.0503 jc)) 360.0))

    ;; Calculate Mean Longitude of the Sun
    (setq l0 (mod (+ 280.46646 (* 36000.76983 jc) (* 0.0003032 (* jc jc))) 360.0))

    ;; Calculate Ecliptic Longitude of the Sun
    (setq c (+ (* (sin (deg-to-rad m)) 1.914602) (* (sin (deg-to-rad (* 2 m))) 0.019993) (* (sin (deg-to-rad (* 3 m))) 0.000289)))
    (setq lambda (+ l0 c))

    ;; Calculate Declination of the Sun
    (setq eps (deg-to-rad (+ 23.439 (- (* 0.00000036 jc)))))
    (setq decl (asin (* (sin eps) (sin (deg-to-rad lambda)))))

    ;; Calculate Hour Angle
    (setq ha (- lst (rad-to-deg lambda)))

    ;; Convert Hour Angle and Latitude to Radians
    (setq ha (deg-to-rad ha))

    ;; Calculate Azimuth in Radians
    (setq azimuth (atan (/ (sin ha) (- (* (cos ha) (sin lat)) (* (tan decl) (cos lat))))))

    azimuth
  )

  ;; User inputs
  
(if (not AH:getvalsm)(load "Multi Getvals.lsp"))
(setq ans (AH:getvalsm (list "Enter values " "Enter latitude" 8 7 "52" "Enter longitude" 8 7 "21" "Enter year" 5 4 "2024" "Enter month" 4 3 "1" "Enter day" 4 3 "1")))
(setq lat (atof (nth 0 ans)))
(setq lon (atof (nth 1 ans)))
(setq year (atoi (nth 2 ans)))
(setq month (atoi (nth 3 ans)))
(setq day (atoi (nth 4 ans)))

  ;; Initialize the list
  (setq time-list '())

  ;; Loop through each minute from 6:00 to 18:00
  (setq hour 6)
  (while (<= hour 18)
    (setq minute 0)
    (while (< minute 60)
      ;; Calculate Julian Date for the current time
      (setq jd (julian-date year month day hour minute 0))
      
      ;; Calculate Sun Azimuth
      (setq azimuth (sun-azimuth lat lon jd))
      
      ;; Create the time string and append to the list
      (setq time-str (strcat (itoa hour) ":" (if (< minute 10) (strcat "0" (itoa minute)) (itoa minute))))
      (setq time-list (append time-list (list (strcat time-str " " (rtos azimuth 2 6)))))
      
      ;; Increment minute
      (setq minute (+ minute 1))
    )
    ;; Increment hour
    (setq hour (+ hour 1))
  )

  ;; Print the list of time and azimuth values
  
(if (not AT:ListSelectAH)(load "listselectAH"))
(setq ans (nth (atoi (AT:ListSelectAH "Avaialable angles" "Choose angle" 20 20 "false" time-list)) time-list))
(setq pos (vl-string-position (ascii " ") ans))
(setq ang (atof  (substr ans (+ 1 pos))))

;; Set Dynamic Block Property Value  -  Lee Mac
;; Modifies the value of a Dynamic Block property (if present)
;; blk - [vla] VLA Dynamic Block Reference object
;; prp - [str] Dynamic Block property name (case-insensitive)
;; val - [any] New value for property
;; Returns: [any] New value if successful, else nil

(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)
    )
)

(command "-insert" "LS" (getpoint "\nPick block point ") 1 1 0)
(setq blk (vlax-ename->vla-object (entlast)))
(LM:setdynpropvalue blk "Angle1" (deg-to-rad ang))
  (princ)
)
(c:sun-azimuth-array)

image.png.1dbb4ad7797a54833abcd451c93e77dd.png

 

Multi GETVALS.lsplistselect.lsp

Edited by BIGAL

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...