Message 1 of 7

Not applicable
01-29-2019
12:12 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I'm new to LISP and trying to get a lisp that goes through all Layouts and "prints" a value of each viewport scale.
I managed to do all of above, but got stuck on a simple sumation problem.
In a case when there is more viewports on layout, or when they are on negative side of paperspace, desired text is not offseting, its like lisp coudn't add offset value "a" to a coordinates. This does not happen when there is only one viewport in positive part of layout.
Do you have any idea what am I doing wrong?
Thanks in advance!
Tomasz
(vl-load-com) (princ "WN- for scale") (defun C:WN (/ intCount intCountLength Scale CenterVar Center CenterX CenterY LAY ssALL intCountLengthDel ) (setq LAY (getvar "ctab")) ;;(setvar "cmdecho" 0) (setq a (float 10)) ;;offset "a" set to 10 (foreach layout (layoutlist) (setvar "ctab" layout) ;;goes through all layuts (progn (setq ssAll(ssget "_X"(list (cons 410 (getvar "ctab")) (cons 0 "Viewport")))) ;;select ALL vieports on selectes layout (setq intCountLengthDel (sslength ssAll)) ;;amount of entities in ss (ssdel (ssname ssAll (1- intCountLengthDel)) ssAll) ;;delete last entity from selection set(layout vieport) (setq intCountLength (sslength ssAll)) (setq intCount intCountLength) (while (> intCount 0) ;;goes through viewports (progn (setq intCount (1- intCount)) (setq entAll (ssname ssAll intCount)) (setq OBJEname (vlax-ename->vla-object entAll)) (setq Scale (vla-Get-CustomScale OBJEname)) ;;read scale value in decimal (setq CenterVar (vla-Get-Center OBJEname)) (setq Center (vlax-safearray->list (vlax-variant-value CenterVar))) (setq Width (vla-Get-Width OBJEname)) (setq CenterX(+ a (- (car Center) (/ (vla-Get-Width OBJEname) 2)))) ;;X coordinates +a (offset) (setq CenterY (+ a (- (cadr Center) (/ (vla-Get-Height OBJEname) 2)))) ;;Y coordinates +a (offset) (command "._text"(list CenterX CenterY)2.5 0(strcat "SCALE 1:" (rtos (/ 1 Scale)))"") ;; ) (princ) ;;progn ) ) (princ) ;;while ) ;;foreach ;;) (setvar "ctab" LAY) ;;(setvar "cmdecho" 1) (princ) )
Solved! Go to Solution.