Bonjour tout le monde,
J'ai une fonction qui permet de changer les hachures d'un calque avec une échelle.
(defun c:HatchReben ()
; Set variables for layer name, new hatch pattern, hatch scales, and hatch color
(setq layerName "01232 - Bodenbedeckung - Reben Füllfläche"
newHatchPattern "GB_REBEN"
hatchscales 0.25
hatchColor '(130 130 130)) ; RGB color (130, 130, 130)
; Check if the specified layer exists
(if (tblsearch "LAYER" layerName)
(progn
; Get information about the existing layer
(setq oldLayer (tblsearch "LAYER" layerName))
(setq oldLayerColor (cdr (assoc 62 oldLayer)))
(setq oldLayerLinetype (cdr (assoc 6 oldLayer)))
(setq oldLayerLinetypescales (cdr (assoc 48 oldLayer)))
)
; Display a message if the layer is not found
(prompt (strcat "\nLayer " layerName " not found."))
)
; Select all hatches on the specified layer
(setq ss (ssget "X" (list (cons 8 layerName) (cons 0 "HATCH"))))
; Check if hatches are found on the specified layer
(if ss
(progn
(setq i 0)
; Loop through each selected hatch
(while (< i (sslength ss))
; Get the entity name of the hatch
(setq hatchEntity (ssname ss i))
; Get the layer of the hatch
(setq hatchLayer (cdr (assoc 8 (entget hatchEntity))))
; Check if the hatch is on the specified layer
(if (= hatchLayer layerName)
(progn
; Modify the hatch entity to change its pattern and scales
(entmod (subst (cons 2 newHatchPattern) (assoc 2 (entget hatchEntity)) (entget hatchEntity)))
(entmod (subst (cons 41 hatchscales) (assoc 41 (entget hatchEntity)) (entget hatchEntity)))
; Change hatch color to RGB (130, 130, 130)
(entmod (subst (cons 62 hatchColor) (assoc 62 (entget hatchEntity)) (entget hatchEntity)))
; Restore original layer properties
(entmod (subst (cons 6 oldLayerLinetype) (assoc 6 (entget hatchEntity)) (entget hatchEntity)))
(entmod (subst (cons 48 oldLayerLinetypescales) (assoc 48 (entget hatchEntity)) (entget hatchEntity)))
)
)
; Move to the next hatch in the selection set
(setq i (1+ i))
)
Le problème c'est que bien que l'échelle soit correcte quand on vérifie sur les propriétés de la hachure, mais visuellement elle ne l'est pas. Si on remodifie manuellement l'échelle en remettant la même valeur (sur cet exemple 0.25) dans les propriétés de la hachure sélectionnée, ca marche.
Quelqu'un aurait il une idée sur la provenance de ce problème?
Je vous remercie d'avance.
Meilleures salutations.