- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone,
I've been trying to write a script that accomplishes the following:
- Let me select a viewport in a layout
- Get the rotation angle of the UCS in relation to the WCS using VIEWTWIST
- Select a specific dynamic block that has a parameter called "Winkel1" (German for: Angle1)
- Apply the number that I got by running VIEWTWIST to that parameter.
Here's the code:
(defun c:autonord()
(setq vp (car (entsel "Select the Viewport: ")))
(setvar "viewport" vp)
(setq angle (getvar "VIEWTWIST"))
(if (< angle 0) (setq angle (+ angle 360)))
(setq blk (car (entsel "Select the dynamic block: ")))
(if (member "Winkel1" (vl-block-dyn-propnames blk))
(command "._ddp" blk "Winkel1" angle "")
)
(princ "Angle value is: " angle)
(princ)
)
And this is the error I've been getting when I run the script and select a viewport:
Error: Settings for AutoCAD variable rejected: "viewport" <objektname: 23b0decadd0>
It would be awesome if any of you could help me with this problem!
I am using ACAD 2022.
Thanks so much in advance!
Solved! Go to Solution.