TuttoCAD Forum

TuttoCAD Forum
[ Home | Registrati | Discussioni Attive | Discussioni Recenti | Segnalibro | Msg privati | Sondaggi Attivi | Utenti | Album Fotografico | Download | | Cerca | FAQ ]
Nome Utente:
Password:
Salva Password
Password Dimenticata?

 Tutti i Forum
 1 - TuttoCAD Software
 AutoLISP
 Get and set layer and entity transparency

Nota: Devi essere registrato per poter inserire un messaggio.
Per registrarti, clicca qui. La Registrazione è semplice e gratuita!

Larghezza finestra:
Nome Utente:
Password:
Modo:
Formato: GrassettoCorsivoSottolineatoBarrato Aggiungi Spoiler Allinea a  SinistraCentraAllinea a Destra Riga Orizzontale Inserisci linkInserisci EmailInserisci FlashInserisci Immagine Inserisci CodiceInserisci CitazioneInserisci Lista
   
Icona Messaggio:              
             
Messaggio:

  * Il codice HTML è OFF
* Il Codice Forum è ON

Faccine
Felice [:)] Davvero Felice [:D] Caldo [8D] Imbarazzato [:I]
Goloso [:P] Diavoletto [):] Occhiolino [;)] Clown [:o)]
Occhio Nero [B)] Palla Otto [8] Infelice [:(] Compiaciuto [8)]
Scioccato [:0] Arrabbiato [:(!] Morto [xx(] Assonnato [|)]
Bacio [:X] Approvazione [^] Disapprovazione [V] Domanda [?]
Seleziona altre faccine

    
 
   

V I S U A L I Z Z A    D I S C U S S I O N E
arri 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)
)

TuttoCAD Forum © 2001-2010 CADLandia Torna all'inizio della Pagina
Pagina generata in 0,31 secondi.