@christophe.bignon a écrit :
Donc vous m'avait conseillé d'utiliser la commande MLIGNE qui est très bien.
Néanmoins cette commande ne me permet pas de créer les lignes parallèles à une courbe (polyligne).
Voila ma question.
Merci
Si ça peut être suffisant pour toi, j'avais fais ce code qui simule au mieux les arcs pour les multilignes.
Il converti des polylignes avec des courbes en multilignes.
(defun def_bulg_pl (ls lb flag_closed / ls lb rad a l_new)
(if (not (zerop flag_closed)) (setq ls (append ls (list (car ls)))))
(while (cadr ls)
(if (zerop (car lb))
(setq l_new (append l_new (list (car ls))))
(progn
(setq
rad (/ (distance (car ls) (cadr ls)) (sin (* 2.0 (atan (abs (car lb))))) 2.0)
a (- (/ pi 2.0) (- pi (* 2.0 (atan (abs (car lb))))))
)
(if (< a 0.0) (setq a (- (* 2.0 pi) a)))
(if (or (and (< (car lb) 0.0) (> (car lb) -1.0)) (> (car lb) 1.0))
(setq l_new (append l_new (reverse (cdr (reverse (bulge_pts (polar (car ls) (- (angle (car ls) (cadr ls)) a) rad) (car ls) (cadr ls) rad (car lb)))))))
(setq l_new (append l_new (reverse (cdr (reverse (bulge_pts (polar (car ls) (+ (angle (car ls) (cadr ls)) a) rad) (car ls) (cadr ls) rad (car lb)))))))
)
)
)
(setq ls (cdr ls) lb (cdr lb))
)
(append l_new (list (car ls)))
)
(defun bulge_pts (pt_cen pt_begin pt_end rad sens / inc ang nm p1 p2 lst)
(setq
inc (angle pt_cen (if (< sens 0.0) pt_end pt_begin))
ang (+ (* 2.0 pi) (angle pt_cen (if (< sens 0.0) pt_begin pt_end)))
nm (fix (/ (rem (- ang inc) (* 2.0 pi)) (/ (* pi 2.0) 36.0)))
)
(repeat nm
(setq
p1 (polar pt_cen inc rad)
inc (+ inc (/ (* pi 2.0) 36.0))
lst (append lst (list p1))
)
)
(setq
p2 (polar pt_cen ang rad)
lst (append lst (list p2))
)
(if (< sens 0.0) (reverse lst) lst)
)
(defun c:polyarc2ml ( / jspl nbr ent dxf_ent typent name_layer closed lst l_bulg e_next dxf_next oldlayer oldosm key_mod scale_ml)
(princ "\nChoix des polylignes à transformer en multilignes: ")
(setq
jspl (ssget '((0 . "*POLYLINE,LINE,CIRCLE,ARC") (-4 . "<NOT") (-4 . "&") (70 . 124) (-4 . "NOT>")))
nbr 0
)
(cond
(jspl
(initget "Dessus Nulle dEssous _Top Zero Bottom")
(setq key_mod
(getkword
(strcat
"\nEntrez le type de justification [Dessus/Nulle/dEssous] <"
(cond
((eq (getvar "cmljust") 0)
"Dessus"
)
((eq (getvar "cmljust") 1)
"Nulle"
)
((eq (getvar "cmljust") 2)
"dEssous"
)
)
">: "
)
)
)
(if key_mod
(cond
((eq key_mod "Top") (setvar "cmljust" 0))
((eq key_mod "Zero") (setvar "cmljust" 1))
((eq key_mod "Bottom") (setvar "cmljust" 2))
)
)
(setq scale_ml (getdist (strcat "\nEntrez l'échelle de la multiligne <" (rtos (getvar "cmlscale")) ">: ")))
(if scale_ml (setvar "cmlscale" scale_ml))
(setq oldlayer (getvar "clayer") oldosm (getvar "osmode"))
(setvar "osmode" 0)
(setvar "cmdecho" 0)
(command "_.ucs" "_world")
(repeat (sslength jspl)
(setq
typent (cdr (assoc 0 (setq dxf_ent (entget (setq ent (ssname jspl nbr))))))
name_layer (cdr (assoc 8 dxf_ent))
)
(cond
((eq typent "LWPOLYLINE")
(setq
closed (boole 1 (cdr (assoc 70 dxf_ent)) 1)
lst (mapcar '(lambda (x) (trans x ent 1)) (mapcar 'cdr (vl-remove-if '(lambda (x) (/= (car x) 10)) dxf_ent)))
l_bulg (mapcar 'cdr (vl-remove-if '(lambda (x) (/= (car x) 42)) dxf_ent))
lst (def_bulg_pl lst l_bulg closed)
)
)
((eq typent "POLYLINE")
(setq
closed (boole 1 (cdr (assoc 70 dxf_ent)) 1)
e_next (entnext ent)
)
(while (= "VERTEX" (cdr (assoc 0 (setq dxf_next (entget e_next)))))
(if (zerop (boole 1 223 (cdr (assoc 70 dxf_next))))
(setq
lst (cons (trans (cdr (assoc 10 dxf_next)) ent 1) lst)
l_bulg (cons (cdr (assoc 42 dxf_next)) l_bulg)
)
)
(setq e_next (entnext e_next))
)
(setq
lst (reverse lst)
l_bulg (reverse l_bulg)
lst (def_bulg_pl lst l_bulg closed)
)
)
((eq typent "LINE")
(setq
lst (list (trans (cdr (assoc 10 dxf_ent)) 0 1) (trans (cdr (assoc 11 dxf_ent)) 0 1))
closed 0
)
)
((eq typent "CIRCLE")
(setq
lst
(bulge_pts
(trans (cdr (assoc 10 dxf_ent)) ent 1)
(polar (trans (cdr (assoc 10 dxf_ent)) ent 1) 0.0 (cdr (assoc 40 dxf_ent)))
(polar (trans (cdr (assoc 10 dxf_ent)) ent 1) (- (* 2.0 pi) (/ (* pi 2.0) 36.0)) (cdr (assoc 40 dxf_ent)))
(cdr (assoc 40 dxf_ent))
1
)
lst (append lst (list (car lst)))
closed 1
)
)
((eq typent "ARC")
(setq
lst
(bulge_pts
(trans (cdr (assoc 10 dxf_ent)) ent 1)
(polar (trans (cdr (assoc 10 dxf_ent)) ent 1) (cdr (assoc 50 dxf_ent)) (cdr (assoc 40 dxf_ent)))
(polar (trans (cdr (assoc 10 dxf_ent)) ent 1) (cdr (assoc 51 dxf_ent)) (cdr (assoc 40 dxf_ent)))
(cdr (assoc 40 dxf_ent))
1
)
closed 0
)
)
)
(cond
(lst
(setvar "clayer" name_layer)
(command "_.mline")
(foreach n lst (command n))
(if (not (zerop closed)) (command "_close") (command ""))
(entdel ent)
)
)
(setq nbr (1+ nbr) lst nil l_bulg nil)
)
(command "_.ucs" "_previous")
(setvar "clayer" oldlayer)
(setvar "osmode" oldosm)
(setvar "cmdecho" 1)
)
(T (princ "\nSélection vide"))
)
(prin1)
)