Jump to content

Recommended Posts

Posted

Hello everyone.
I'm new to the forum and I'm trying to write some Lisp code. I'm showing you a snippet of one of the main functions. Through a previously loaded DCL, I get a menu from which I activate a submenu that I call 'panvps'. From there, I set a value, and what I intend is for it to go through the entire drawing, moving the interior of the viewport of each layout by that determined value. The function itself works fine outside of this more complex code, but I can't resolve the interaction between the closing dialogs, and the VEVAL-STR+ ARX error appears. Can anyone help me? Thanks in advance
 

defun _addtab (dchand / shiftY result allLayouts layouts layoutName newCenter layoutNum baseCenter baseHeight)
  (cond
    ((not (new_dialog "panvps" dchand))
      (princ "\n** Error loading PANVPS dialog **")
    )
    (t
      (set_tile "shiftY" "100") ; Default value

      (action_tile "accept"
        (vl-prin1-to-string
          '(progn
             (setq shiftY (atof (get_tile "shiftY")))
             (done_dialog 1)  ; Close panvps
             (done_dialog 1)  ; Close main dialog 
           )
        )
      )

      (action_tile "cancel" "(done_dialog 0)")

      (setq result (start_dialog))

      (if (= result 1)
        (progn
          (princ "\nAlready closed")

          ;;; START LAYOUT PROCESSING ;;;
          (vl-load-com)
          (setq allLayouts (layoutlist))
          (setq layouts (vl-remove-if-not
                          '(lambda (x) (wcmatch x "*N[0-9][0-9].*"))
                          allLayouts))

          (if (not layouts)
            (progn
              (alert "No layouts found with XXX.NXX.Example format to process.")
              (exit)
            )
          )

          (setvar "TILEMODE" 0)
          (command "._layout" "_Set" (car layouts))
          (command "._mspace")

          (setq baseCenter (getvar "VIEWCTR"))
          (setq baseHeight (getvar "VIEWSIZE"))

          (foreach layoutName layouts
            (setq layoutNum (atoi (substr layoutName
                                        (+ (vl-string-position (ascii "N") layoutName) 2)
                                        2)))
            (if (not (vl-catch-all-error-p
                      (vl-catch-all-apply
                        '(lambda ()
                           (command "._layout" "_Set" layoutName)
                           (command "._mspace")
                           (setq newCenter (list (car baseCenter)
                                               (+ (cadr baseCenter) (* shiftY layoutNum))))
                           (command "._zoom" "_C" newCenter baseHeight)
                           (command "._pspace")
                         )
                      )))
              (princ (strcat "\nProcessed layout: " layoutName))
            )
          )
          (princ (strcat "\nViewports adjusted. Offset: " (rtos shiftY 2 2)))
          ;;; END LAYOUT PROCESSING ;;;
        )
        (princ "\nOperation cancelled")
      )
    )
  )
  (princ)
)

 

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...