AutoLISP not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone,
I've got problems with this script of mine... Still have to learn a lot.
So basically I want to write a AutoLISP that does the following:
- Let the user select a viewport
- retrieve the scale factor of that viewport by using PSVPSCALE
- then it should let the user select a dynamic block
- change one parameter of that dyn. block called "Abrufen2" (which is a lookup parameter) based on these correlations:
Import property - viewport scale variable
1.0 - 50
2.0 - 25
3.0 - 20
4.0 - 15
5.0 - 10
6.0 - 5
7.0 - 2.5
8.0 - 2
9.0 - 1.5
10.0 - 1.25
11.0 - 1
12.0 - 0.5
13.0 - 0.25
14.0 - 0.2
15.0 - 0.15
16.0 - 0.1
17.0 - 0.05
18.0 - 0.025
19.0 - 0.02
20.0 - 0.01
So if the scale factor is 0.5, I'd like it to change the import property to 12.0
The import properties are already in the lookup action table.
Here's the code so far:
(defun c:automassstab()
(vl-load-com)
(setq vp (getvar "PSVPSCALE"))
(setq vpname (entsel "Select viewport: "))
(if vpname
(progn
(setq vpname (cadr vpname))
(setq bname (entsel "Select the dynamic block: "))
(if bname
(progn
(setq bname (cadr bname))
(setq props (entget bname))
(setq scale_lookup_table '((50 . 1.0) (25 . 2.0) (20 . 3.0) (15 . 4.0) (10 . 5.0) (5 . 6.0) (2.5 . 7.0) (2 . 8.0) (1.5 . 9.0) (1.25 . 10.0) (1 . 11.0) (0.5 . 12.0) (0.25 . 13.0) (0.2 . 14.0) (0.15 . 15.0) (0.1 . 16.0) (0.05 . 17.0) (0.025 . 18.0) (0.02 . 19.0) (0.01 . 20.0)))
(setq scale (vl-position vp (mapcar 'car scale_lookup_table)))
(if (assoc "Abrufen2" props)
(entmod (subst (cons "Abrufen2" (cdr (nth scale scale_lookup_table))) (assoc "Abrufen2" props) props))
(princ "Selected block does not have the necessary parameter called 'Abrufen2'.")
)
)
)
)
)
)
But I get the Error:
Incorrect argument type: lentityp (607.639 25.2777 0.0)
Maybe some of you all can help me with this. - Thanks