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

Can you help me to correct my lisp

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
taiki84
505 Views, 11 Replies

Can you help me to correct my lisp

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)

11 REPLIES 11
Message 2 of 12
pbejse
in reply to: taiki84


@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

Message 3 of 12
taiki84
in reply to: pbejse

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.

Message 4 of 12
pbejse
in reply to: taiki84

If you dont mind, post a drawing file where we can test the code for better understanding

Message 5 of 12
taiki84
in reply to: pbejse

Two drawing "original" for test and the result.

 

thanks

Message 6 of 12
pbejse
in reply to: taiki84

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.

 

Message 7 of 12
taiki84
in reply to: pbejse

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.

 

 

Message 8 of 12
pbejse
in reply to: taiki84

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

Message 9 of 12
taiki84
in reply to: pbejse

Ok that work but he don't appli the same proprieties at the new layers.

 

Thanks

Message 10 of 12
pbejse
in reply to: taiki84

Revised [Still not sure if it works for all conditions]

Message 11 of 12
taiki84
in reply to: pbejse

Ok he work fine 

 

thanks for your help

Message 12 of 12
pbejse
in reply to: taiki84


@taiki84 wrote:

Ok he work fine 

 

thanks for your help


Good for you, Glad i could help.

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

Post to forums  

Autodesk Design & Make Report

”Boost