Jump to content

'VLIDE too many arguments (repeat not functioning as expected)


nzoro99

Recommended Posts

Hello,

If I run each line of this section of code it works , but if I incorporate it in modified VPSEL lisp, it gets stacked somewhere. Lisp doesn't stop on error, neither on break toggle. I wonder if I need (else parameter in (if                            .and if I need else parameter indeed I don't know how tell the lisp continue to next item.

(setq data ss1)

(setq i 0)
(repeat	(sslength data)
  (setq e (ssname data i))
  (if (and (< i (sslength data))
	   (equal "DIMENSION" (cdr (assoc 0 (entget e))))
      )


    (setq entdimnstyle (entget e))
    (setq newdim (subst	(cons 3 "NewDimension")
			(assoc 3 entdimnstyle)
			entdimnstyle
		 )
	  (entmod newdim)
    )
    
    (setq i (1+ i))
  )

)

)

and here is the complete code

;;;---------------------------------------------------------------------------;
;;;
;;; vpsel.lsp
;;;
;;; By Jimmy Bergmark
;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved
;;; Website: www.jtbworld.com
;;; E-mail: info@jtbworld.com
;;;
;;; 2000-04-14 - First release
;;; Tested on AutoCAD 2000
;;;
;;;---------------------------------------------------------------------------;
;;;  DESCRIPTION
;;;
;;;  Select all visible objects in selected or active paperspace viewport
;;;  Works transparently when in modelspace and for polygonal viewports too
;;;  Example1: ERASE ALL R 'VPC >>> Erase all in model except what is visible
;;;  Example2: (command "erase" "all" "r" (c:vpc) "")
;;;  Example3: VPC ERASE >>> VPC is run previous the command and the objects
;;;                            are also in previous selection set
;;;
;;;  c:vpc - select all visible objects with crossing in viewport
;;;  c:vpw - select all visible objects with window in viewport
;;;---------------------------------------------------------------------------;

(defun c:vpttt ()
  (vpselttt "C")
  (princ)
)

(defun c:vpwttt ()
  (vpselttt "W")
  (princ)
)

(defun dxf (n ed) (cdr (assoc n ed)))

(defun vpselttt (typ   /     ad    ss    ent   vpno  ok    vpbl  vpur
              msbl  msur  msul  mslr  ss1   pl    nlist x     n
             )
  (vl-load-com)
  (setq ok t)
  (if (= (getvar "tilemode") 0)
    (progn
      (setq ad (vla-get-activedocument (vlax-get-acad-object)))
      (if (= (getvar "cvport") 1)
        (if (and (= (getvar "cmdactive") 0)
                (setq ss (ssget "_x" (list '(0 . "VIEWPORT")))) 
            )
          (progn
            (setq ent (ssname ss 2))
            (setq vpno (dxf 69 (entget ent)))
            (vla-Display (vla-get-activepviewport ad) :vlax-true)
            (vla-put-mspace ad :vlax-true)
            (setvar "cvport" vpno)
          )
          (progn
            (setq ok nil)
          )
        )
        (setq ent (vlax-vla-object->ename (vla-get-activepviewport ad)))
      )
      (if (and ok (/= 1 (logand 1 (dxf 90 (setq ed (entget ent))))))
        (progn
          (if (= (vla-get-clipped (vlax-ename->vla-object ent))
                 :vlax-false
              )
            (progn
              (vla-getboundingbox
                (vla-get-activepviewport ad)
                'vpbl
                'vpur
              )
              (setq msbl (trans (vlax-safearray->list vpbl) 3 2))
              (setq msur (trans (vlax-safearray->list vpur) 3 2))
              (setq msul (list (car msbl) (cadr msur)))
              (setq mslr (list (car msur) (cadr msbl)))
              (setq ss1
                     (ssget (strcat typ "P") (list msbl msul msur mslr))
              )
            )
;;;           (progn
;;;              (setq pl (entget (dxf 340 (entget ent))))
;;;              (setq nlist nil)
;;;              (foreach x pl
;;;                (if (eq 10 (car x))
;;;                  (setq nlist (cons (trans (cdr x) 3 2) nlist))
;;;                )
;;;              )
;;;              (setq ss1 (ssget (strcat typ "P") nlist))
;;;            )
          )
          (sssetfirst nil ss1)
          (if ss1
            (setq n (sslength ss1))
            (setq n 0)
          )
          (princ n)
          (princ " found ")
          (if (and ss1 (= (getvar "cmdactive") 1))
            ss1
          )
        )
      )
    )
  )
;;;  (setq ss nil ss1 nil)
(setq data ss1)

(setq i 0)
(repeat	(sslength data)
  (setq e (ssname data i))
  (if (and (< i (sslength data))
	   (equal "DIMENSION" (cdr (assoc 0 (entget e))))
      )


    (setq entdimnstyle (entget e))
    (setq newdim (subst	(cons 3 "NewDimension")
			(assoc 3 entdimnstyle)
			entdimnstyle
		 )
	  (entmod newdim)
    )
    
    (setq i (1+ i))
  )

)

)

(princ)

 

Thank you for the input!

Edited by nzoro99
Link to comment
Share on other sites

This worked for me

;;;---------------------------------------------------------------------------;
;;;
;;; vpsel.lsp
;;;
;;; By Jimmy Bergmark
;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved
;;; Website: www.jtbworld.com
;;; E-mail: info@jtbworld.com
;;;
;;; 2000-04-14 - First release
;;; Tested on AutoCAD 2000
;;;
;;;---------------------------------------------------------------------------;
;;;  DESCRIPTION
;;;
;;;  Select all visible objects in selected or active paperspace viewport
;;;  Works transparently when in modelspace and for polygonal viewports too
;;;  Example1: ERASE ALL R 'VPC >>> Erase all in model except what is visible
;;;  Example2: (command "erase" "all" "r" (c:vpc) "")
;;;  Example3: VPC ERASE >>> VPC is run previous the command and the objects
;;;                            are also in previous selection set
;;;
;;;  c:vpc - select all visible objects with crossing in viewport
;;;  c:vpw - select all visible objects with window in viewport
;;;---------------------------------------------------------------------------;

(defun c:vpttt ()
  (vpselttt "C")
  (princ)
)

(defun c:vpwttt ()
  (vpselttt "W")
  (princ)
)

(defun dxf (n ed) (cdr (assoc n ed)))

(defun vpselttt (typ   /     ad    ss    ent   vpno  ok    vpbl  vpur
              msbl  msur  msul  mslr  ss1   pl    nlist x     n
             )
  (vl-load-com)
  (setq ok t)
  (if (= (getvar "tilemode") 0)
    (progn
      (setq ad (vla-get-activedocument (vlax-get-acad-object)))
      (if (= (getvar "cvport") 1)
        (if (and (= (getvar "cmdactive") 0)
                (setq ss (ssget "_x" (list '(0 . "VIEWPORT")))) 
            )
          (progn
            (setq ent (ssname ss 2))
            (setq vpno (dxf 69 (entget ent)))
            (vla-Display (vla-get-activepviewport ad) :vlax-true)
            (vla-put-mspace ad :vlax-true)
            (setvar "cvport" vpno)
          )
          (progn
            (setq ok nil)
          )
        )
        (setq ent (vlax-vla-object->ename (vla-get-activepviewport ad)))
      )
      (if (and ok (/= 1 (logand 1 (dxf 90 (setq ed (entget ent))))))
        (progn
          (if (= (vla-get-clipped (vlax-ename->vla-object ent))
                 :vlax-false
              )
            (progn
              (vla-getboundingbox
                (vla-get-activepviewport ad)
                'vpbl
                'vpur
              )
              (setq msbl (trans (vlax-safearray->list vpbl) 3 2))
              (setq msur (trans (vlax-safearray->list vpur) 3 2))
              (setq msul (list (car msbl) (cadr msur)))
              (setq mslr (list (car msur) (cadr msbl)))
              (setq ss1
                     (ssget (strcat typ "P") (list msbl msul msur mslr))
              )
            )
;;;           (progn
;;;              (setq pl (entget (dxf 340 (entget ent))))
;;;              (setq nlist nil)
;;;              (foreach x pl
;;;                (if (eq 10 (car x))
;;;                  (setq nlist (cons (trans (cdr x) 3 2) nlist))
;;;                )
;;;              )
;;;              (setq ss1 (ssget (strcat typ "P") nlist))
;;;            )
          )
          (sssetfirst nil ss1)
          (if ss1
            (setq n (sslength ss1))
            (setq n 0)
          )
          (princ n)
          (princ " found ")
          (if (and ss1 (= (getvar "cmdactive") 1))
            ss1
          )
        )
      )
    )
  )
;;;  (setq ss nil ss1 nil)
(setq data ss1)

(setq i 0)
(repeat	(sslength data)
  (setq e (ssname data i))
  (if
    (and (< i (sslength data))
	   (equal "DIMENSION" (cdr (assoc 0 (entget e))))
      )

(progn
    (setq entdimnstyle (entget e))
    (setq newdim (subst	(cons 3 "NewDimension")
			(assoc 3 entdimnstyle)
			entdimnstyle
		 )
	  )
	  (entmod newdim)
 (setq i (1+ i))
  )
   
   

 (setq i (1+ i))

)
)

)

(princ)

 

Link to comment
Share on other sites

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