arri
Utente Master
Regione: Lombardia
14951 Messaggi |
Inserito il - 02 maggio 2013 : 11:02:30
|
The properties that you access when using the COM helpers of LISP are based on the ActiveX API.
If you look for the Transparency property in the ActiveX API, then you’ll find that it is only available for AcadRasterImage and AcadWipeout entities.
The Transparency for entities (which is only available in AutoCAD 2011) is provided by new interfaces like IAcadEntity2 and they are called EntityTransparency.
In case of layers however, there is no property like that.
That transparency value can be calculated from the layer’s XData. If it’s not there, then it’s the default 0%
; gets transparency in percentage (defun getLayerTransparency (layerName / layer transparency) (setq layer (tblobjname "LAYER" layerName)) ; get the XData of AcCmTransparency (setq transparency (cdr (assoc 1071 (cdar (cdr (assoc -3 (entget layer '("AcCmTransparency")))))))) (if (= transparency nil) ; if we did not get a value it must be the default 0% (setq transparency 0) ; if we got a value then calculate from it (progn ; get the lower byte of the value 0..255 ; (100%..0% in the AutoCAD user interface) (setq transparency (lsh (lsh transparency 24) -24)) ; convert the value to a percentage (setq transparency (fix (- 100 (/ transparency 2.55)))) ) ; (progn ) ; (if )
(defun c:testGet (/ ent layerName transparency) (setq ent (car (entsel))) (setq layerName (cdr (assoc 8 (entget ent)))) (setq transparency (getLayerTransparency layerName)) (princ transparency) (princ) )
It does not seem possible to set the value the same way - by adjusting the XData value -, but you can use the _LAYER command for that:
(defun c:testSet (/ ent layerName transparency) (setq ent (car (entsel))) (setq transparency (getint "Transparency value")) (setq layerName (cdr (assoc 8 (entget ent)))) (command "_LAYER" "_TR" transparency layerName "") (princ) )
|
|