Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

routine doesn't work first time, but there after???

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
202 Views, 3 Replies

routine doesn't work first time, but there after???

hi

i'm having a bit of trouble with the following routine... it removes a
vertex from a polyline. the problem is that it doesn't work the first time
its run, but works everytime after that.... any help would be great

cheers

mark



(defun C:RV (/ *CURR_OSNAP olderror
SelectedEntity PolyProperties iCount
iCount2 NewPoly
)

;
;;; does not change the vertex on the first run through
;

(setq *CURR_OSNAP (getvar "osmode"))
(setq olderror *error*)
(setq *error* RVLispError)

(setvar "cmdecho" 0)
(command "undo" "begin")
(setvar "osmode" 0)

(setq SelectedEntity (car (entsel "\nSpecify polyline: ")))

(if (and (/= SelectedEntity nil)
(= (cdr (assoc 0 (entget SelectedEntity))) "LWPOLYLINE")
)
(progn
(setq PolyProperties (entget SelectedEntity))

(initget 1)
(setvar "osmode" 32)
(setq SelectedVertex (getpoint "\nSpecify vertex to remove: "))

(setq iCount 0)
(while (< iCount (cdr (assoc 90 PolyProperties)))
(setq VertexPosition
(cdr (nth (+ (* iCount 4) 14) PolyProperties))
)

(if (and (= (car VertexPosition) (car SelectedVertex))
(= (cadr VertexPosition) (cadr SelectedVertex))
)
(progn
(setq iCount2 0)
(while (< iCount2 4)

(setq NewPoly
(vL-remove (nth (+ (* iCount 4) 14) PolyProperties)
PolyProperties
)
)
(setq iCount2 (1+ iCount2))
) ;while

(setq
NewPoly (subst
(cons
90
(1- (cdr (assoc 90 PolyProperties)))
)
(assoc 90 PolyProperties)
NewPoly
)
)
(entmod NewPoly)
(entupd (cdr (assoc -1 NewPoly)))

(setq iCount (cdr (assoc 90 PolyProperties)))
) ;progn
) ;if
(setq iCount (1+ iCount))
) ;while
) ;progn

(prompt "\nNo polylines selected!")
) ;if

(RVCleanUp)

(princ)
)

(princ)
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

This works ok for me. I had to comment out (RVCleanUp) since you didn't
include it.
Maybe the problem is in there.

"Mark Dubbelaar" wrote in message
news:6FFD3A8291E473AEF4BB63E9B34B0629@in.WebX.maYIadrTaRb...
> hi
>
> i'm having a bit of trouble with the following routine... it removes a
> vertex from a polyline. the problem is that it doesn't work the first time
> its run, but works everytime after that.... any help would be great
>
> cheers
>
> mark
>
>
>
> (defun C:RV (/ *CURR_OSNAP olderror
> SelectedEntity PolyProperties iCount
> iCount2 NewPoly
> )
>
> ;
> ;;; does not change the vertex on the first run through
> ;
>
> (setq *CURR_OSNAP (getvar "osmode"))
> (setq olderror *error*)
> (setq *error* RVLispError)
>
> (setvar "cmdecho" 0)
> (command "undo" "begin")
> (setvar "osmode" 0)
>
> (setq SelectedEntity (car (entsel "\nSpecify polyline: ")))
>
> (if (and (/= SelectedEntity nil)
> (= (cdr (assoc 0 (entget SelectedEntity))) "LWPOLYLINE")
> )
> (progn
> (setq PolyProperties (entget SelectedEntity))
>
> (initget 1)
> (setvar "osmode" 32)
> (setq SelectedVertex (getpoint "\nSpecify vertex to remove: "))
>
> (setq iCount 0)
> (while (< iCount (cdr (assoc 90 PolyProperties)))
> (setq VertexPosition
> (cdr (nth (+ (* iCount 4) 14) PolyProperties))
> )
>
> (if (and (= (car VertexPosition) (car SelectedVertex))
> (= (cadr VertexPosition) (cadr SelectedVertex))
> )
> (progn
> (setq iCount2 0)
> (while (< iCount2 4)
>
> (setq NewPoly
> (vL-remove (nth (+ (* iCount 4) 14) PolyProperties)
> PolyProperties
> )
> )
> (setq iCount2 (1+ iCount2))
> ) ;while
>
> (setq
> NewPoly (subst
> (cons
> 90
> (1- (cdr (assoc 90 PolyProperties)))
> )
> (assoc 90 PolyProperties)
> NewPoly
> )
> )
> (entmod NewPoly)
> (entupd (cdr (assoc -1 NewPoly)))
>
> (setq iCount (cdr (assoc 90 PolyProperties)))
> ) ;progn
> ) ;if
> (setq iCount (1+ iCount))
> ) ;while
> ) ;progn
>
> (prompt "\nNo polylines selected!")
> ) ;if
>
> (RVCleanUp)
>
> (princ)
> )
>
> (princ)
>
>
Message 3 of 4
Anonymous
in reply to: Anonymous

There's a vertex remover example on my Freebies page. Hope it helps.

--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ


"Mark Dubbelaar" wrote in message
news:6FFD3A8291E473AEF4BB63E9B34B0629@in.WebX.maYIadrTaRb...
> hi
>
> i'm having a bit of trouble with the following routine... it removes a
> vertex from a polyline. the problem is that it doesn't work the first time
> its run, but works everytime after that.... any help would be great
>
> cheers
>
> mark
>
>
>
> (defun C:RV (/ *CURR_OSNAP olderror
> SelectedEntity PolyProperties iCount
> iCount2 NewPoly
> )
>
> ;
> ;;; does not change the vertex on the first run through
> ;
>
> (setq *CURR_OSNAP (getvar "osmode"))
> (setq olderror *error*)
> (setq *error* RVLispError)
>
> (setvar "cmdecho" 0)
> (command "undo" "begin")
> (setvar "osmode" 0)
>
> (setq SelectedEntity (car (entsel "\nSpecify polyline: ")))
>
> (if (and (/= SelectedEntity nil)
> (= (cdr (assoc 0 (entget SelectedEntity))) "LWPOLYLINE")
> )
> (progn
> (setq PolyProperties (entget SelectedEntity))
>
> (initget 1)
> (setvar "osmode" 32)
> (setq SelectedVertex (getpoint "\nSpecify vertex to remove: "))
>
> (setq iCount 0)
> (while (< iCount (cdr (assoc 90 PolyProperties)))
> (setq VertexPosition
> (cdr (nth (+ (* iCount 4) 14) PolyProperties))
> )
>
> (if (and (= (car VertexPosition) (car SelectedVertex))
> (= (cadr VertexPosition) (cadr SelectedVertex))
> )
> (progn
> (setq iCount2 0)
> (while (< iCount2 4)
>
> (setq NewPoly
> (vL-remove (nth (+ (* iCount 4) 14) PolyProperties)
> PolyProperties
> )
> )
> (setq iCount2 (1+ iCount2))
> ) ;while
>
> (setq
> NewPoly (subst
> (cons
> 90
> (1- (cdr (assoc 90 PolyProperties)))
> )
> (assoc 90 PolyProperties)
> NewPoly
> )
> )
> (entmod NewPoly)
> (entupd (cdr (assoc -1 NewPoly)))
>
> (setq iCount (cdr (assoc 90 PolyProperties)))
> ) ;progn
> ) ;if
> (setq iCount (1+ iCount))
> ) ;while
> ) ;progn
>
> (prompt "\nNo polylines selected!")
> ) ;if
>
> (RVCleanUp)
>
> (princ)
> )
>
> (princ)
>
>
Message 4 of 4
Anonymous
in reply to: Anonymous

There's a vla function for vertex remove in www.acadx.com

Not affiliated
--
Rudy@Cadentity.com
AUTODESK
Authorized Developer
www.Cadentity.com
MASi


"Mark Dubbelaar" wrote in message
news:6FFD3A8291E473AEF4BB63E9B34B0629@in.WebX.maYIadrTaRb...
> hi
>
> i'm having a bit of trouble with the following routine... it removes a
> vertex from a polyline. the problem is that it doesn't work the first time
> its run, but works everytime after that.... any help would be great
>
> cheers
>
> mark
>
>
>
> (defun C:RV (/ *CURR_OSNAP olderror
> SelectedEntity PolyProperties iCount
> iCount2 NewPoly
> )
>
> ;
> ;;; does not change the vertex on the first run through
> ;
>
> (setq *CURR_OSNAP (getvar "osmode"))
> (setq olderror *error*)
> (setq *error* RVLispError)
>
> (setvar "cmdecho" 0)
> (command "undo" "begin")
> (setvar "osmode" 0)
>
> (setq SelectedEntity (car (entsel "\nSpecify polyline: ")))
>
> (if (and (/= SelectedEntity nil)
> (= (cdr (assoc 0 (entget SelectedEntity))) "LWPOLYLINE")
> )
> (progn
> (setq PolyProperties (entget SelectedEntity))
>
> (initget 1)
> (setvar "osmode" 32)
> (setq SelectedVertex (getpoint "\nSpecify vertex to remove: "))
>
> (setq iCount 0)
> (while (< iCount (cdr (assoc 90 PolyProperties)))
> (setq VertexPosition
> (cdr (nth (+ (* iCount 4) 14) PolyProperties))
> )
>
> (if (and (= (car VertexPosition) (car SelectedVertex))
> (= (cadr VertexPosition) (cadr SelectedVertex))
> )
> (progn
> (setq iCount2 0)
> (while (< iCount2 4)
>
> (setq NewPoly
> (vL-remove (nth (+ (* iCount 4) 14) PolyProperties)
> PolyProperties
> )
> )
> (setq iCount2 (1+ iCount2))
> ) ;while
>
> (setq
> NewPoly (subst
> (cons
> 90
> (1- (cdr (assoc 90 PolyProperties)))
> )
> (assoc 90 PolyProperties)
> NewPoly
> )
> )
> (entmod NewPoly)
> (entupd (cdr (assoc -1 NewPoly)))
>
> (setq iCount (cdr (assoc 90 PolyProperties)))
> ) ;progn
> ) ;if
> (setq iCount (1+ iCount))
> ) ;while
> ) ;progn
>
> (prompt "\nNo polylines selected!")
> ) ;if
>
> (RVCleanUp)
>
> (princ)
> )
>
> (princ)
>
>

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost