Hello
I have two question,
First can you help me to correct this lisp?
Second i want to add a function that convert attibutes layers to 0.
(defun c:clb ( / *error* om js js_all n fence js_ins nb Counter )
(princ "\nSélectionnez les polylignes: ")
(or
(setq js (ssget "_I" '((0 . "POLYLINE,LINE,LWPOLYLINE"))))
(setq js (ssget "_P" '((0 . "POLYLINE,LINE,LWPOLYLINE"))))
);or
(cond
(js
(sssetfirst nil js)
(initget "Existant Nouveau _Existent New")
(if (eq (getkword "\nTraiter jeu de sélection [Existant/Nouveau] <Existant>: ") "New")
(progn (sssetfirst nil nil) (setq js (ssadd) js (ssget)))
);js
);cond
(T
(setq js (ssget '((0 . "POLYLINE,LINE,LWPOLYLINE"))))
);t
);or
(progn
(setq js_all (ssadd)
om (getvar "attmode")
)
(setvar "attmode" 0)
(command "_regen")
(cond
(js
(repeat (setq n (sslength js))
(setq
fence (listpol (ssname js (setq n (1- n))))
js_ins (ssget "_F" fence '((0 . "INSERT")))
);setq
(cond
(js_ins
(repeat (setq nb (sslength js_ins))
(ssadd (ssname js_ins (setq nb (1- nb))) js_all)
);repat2
);ji_ins
);cond2
);repeat1
);js
);cond
(setvar "ATTMODE" om)
(command "_.REGEN")
);progn
(prompt "\nSelectioner un objet sur le calque de déstination: ")
(setq Clayer (cdr (assoc 8 (entget (car (entsel))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq Counter (- (sslength js_all) 1 ))
(while (/= Counter -1)
(setq EntList (entget (ssname js_all Counter)))
(setq EntList (subst (cons 8 Clayer)(assoc 8 EntList) EntList))
(entmod EntList)
(setq Counter (1- Counter))
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq a "_POINT")
(if (sslength js_all)
(setq e (entget js_all)
x (assoc 8 e)
n (strcat (cdr x) a)
)
(entmod (subst (cons 8 n) x e))
(if (not (member n l))
(progn
(setq l (cons n l)
e (entget (tblobjname "layer" (cdr x)))
d (entget (tblobjname "layer" n))
)
(foreach k '(-1 2 5)
(setq e (subst (assoc k d) (assoc k e) e))
)
(entmod e)
)
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(sssetfirst nil js_all)
(prin1)
);defun
;;; listpol by Gille Chanteau ;
;;; Returns the vertices list of any type of polyline (WCS coordinates) ;
;;; ;
;;; Argument ;
;;; en, a polyline (ename or vla-object) ;
(defun listpol (en / i p l)
(setq i
(if (vlax-curve-IsClosed en)
(vlax-curve-getEndParam en)
(+ (vlax-curve-getEndParam en) 1)
);if
);seetq i
(while (setq p (vlax-curve-getPointAtParam en (setq i (1- i))))
(setq l (cons (trans p 0 1 ) l))
);while
);defun
;; Tharwat 23.05.2014 ;;
(defun *error* (msg)
(if om
(setvar "ATTMODE" om)
)
(command "_.REGEN")
(if (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")
(princ msg)
(princ (strcat "Error : < ** " msg " ** >"))
)
)
(princ "\nchange layer blocks on polyline with or without pre-selection....loaded.")
(terpri)
(princ "command clb")
(print)
Solved! Go to Solution.
Solved by pbejse. Go to Solution.
@taiki84 wrote:
Hello
I have two question,
First can you help me to correct this lisp?
Second i want to add a function that convert attibutes layers to 0.
First, whats wrong with it? and what is it supposed to do? give us a brief description what the code is all about
Second , Attribute layers to 0 is easy
Sorry
This lisp change layer of blocks by selection with a polyline.
Just the probleme is i want to create a layer for the selected blocks with the same name as the polyline adding a suffix and keep propriete of original layer. and convert one attribute to layer 0 and the second attribute to invisible.
My lisp select correctly blocks deplace on the layers of my choice, but he not add suffix.
And just can you give me the way to look for convert attributes.
Thanks a lot for your help.
Okay hang on...
EDIT: Cant seem to understand the logic of you're original code taiki84, I may end up writing an entirely new code. Will that be acceptable? otherwise it would take me more time trying to figure out what to change on your code.
Ok thanks for your help,
if you have the time to write a new code to do the same, i'll take it for undertand and change mine.
Not sure if this modified lisp will work for you, I tried as much as possible not to deviate from your original code.
See attached LSP file