Re: Layer Transparency

#3
Hi Quan, Happy New Year :) :)
Thanks for the link, sadly that went way over my head :(

I am creating a new layer & setting it's attributes
This is where I am so far:

Code: Select all

	(entmakex 
  		(list
			(cons 0 "LAYER")							;defines create new layer
			(cons 100 "AcDbSymbolTableRecord")
			(cons 100 "AcDbLayerTableRecord")
			(cons 2 "Insulation")							; Layer name
			(cons 62 2)               						; Layer color
			(cons 440 65)               						; Layer Transparency
		);end list
	);end entmake
The layer is created, colour set to 2 (yellow) but the transparency (code 440) is ignored. :(

SteveN
CMS INTELLICAD 12.1.243.153262.PE+.VC16.x64.CMS121

i9-12900k / 64gb-3200 - NVIDIA GeForce TRX 3060 Ti 8Gb Windows 11 Pro
www.stylemarkdesigns.co.uk

Re: Layer Transparency

#4
Please try this:

Code: Select all

(defun C:entmakeLayer ()
  (regapp "accmtransparency")
  (entmakex
    (list
      (cons 0 "LAYER")
      (cons 100 "AcDbSymbolTableRecord")
      (cons 100 "AcDbLayerTableRecord")
      (cons 2  "LayerTranparence") 	;layer name
      (cons 6  "Continuous") 		;linetype
      ;(cons 370  LWeight) 		;lineWeight
      (cons 62  2) 			;layer color
      (cons 70 0) 			; on, unlocked, thawed
      (cons 290 1) 			;Plot/No Plot : 0->No plot
      (cons -3	    			;transparency
	    (list(list "accmtransparency"
		       (cons 1071 (LM:trans->dxf 61))	) ) )
      )
    )
  (princ))

Re: Layer Transparency

#5
Hi Quan,
Thanks for the code.
I had to go to the thread you kinked to as part of your code failed.
It errored here : LM:trans->dxf

copied this and all is good now :)

Code: Select all

(defun LM:trans->dxf ( x )
    (logior (fix (* 2.55 (- 100 x))) 33554432)
)
.
Most of your code I understand, but this confuses me, can you explain a little please?

Code: Select all

			(cons -3	    						; transparency
				(list(list "accmtransparency"
				(cons 1071 (LM:trans->dxf 65))	) ) )
CMS INTELLICAD 12.1.243.153262.PE+.VC16.x64.CMS121

i9-12900k / 64gb-3200 - NVIDIA GeForce TRX 3060 Ti 8Gb Windows 11 Pro
www.stylemarkdesigns.co.uk

Re: Layer Transparency

#6
This is where the codes is atm.
I've also added a check for the layer existance.

Code: Select all

(defun MKLAY_INS ( / ) 
	(if (tblsearch "layer" "Insulation") (DRAW_CD)
	(progn
	(regapp "accmtransparency")
	(entmakex 
  		(list
			(cons 0 "LAYER")					;defines create new layer
			(cons 100 "AcDbSymbolTableRecord")
			(cons 100 "AcDbLayerTableRecord")
			(cons 2 "Insulation")					; Layer name
;			(cons 6  "Continuous") 					; linetype
;	    		(cons 370  LWeight) 					; lineWeight
			(cons 62 2)               				; Layer color
;   			(cons 70 0) 						; on, unlocked, thawed
;			(cons 290 1) 						; Plot/No Plot : 0->No plot
			(cons -3	    					; transparency
				(list(list "accmtransparency"			; transparency
				(cons 1071 (LM:trans->dxf 65))	) ) )		; transparency
		);end list
	);end entmake
	);end progn
	); end If 
	(DRAW_CD)
CMS INTELLICAD 12.1.243.153262.PE+.VC16.x64.CMS121

i9-12900k / 64gb-3200 - NVIDIA GeForce TRX 3060 Ti 8Gb Windows 11 Pro
www.stylemarkdesigns.co.uk

Re: Layer Transparency

#7
I am having issues with the code below, in that if the kayer 'Insulation' does not exist the layer is created
and everyting works fine.
However
If the layer exists everything executes as expected, but at the end the (CD_SHAPE) is exucuting a second time??
.

Code: Select all

; Create Insulation Layer + layer attributes
(defun MKLAY_INS () 
(princ "\n start MKLAY_INS ")
;
	(if (tblsearch "layer" "Insulation")(CD_SHAPE)
	(progn
	(regapp "accmtransparency")
	(entmakex 
  		(list
			(cons 0 "LAYER")						;defines create new layer
			(cons 100 "AcDbSymbolTableRecord")
			(cons 100 "AcDbLayerTableRecord")
			(cons 2 "Insulation")					; Layer name
;			(cons 6  "Continuous") 					; linetype
;	    	(cons 370  LWeight) 					; lineWeight
			(cons 62 2)               				; Layer color
;   		(cons 70 0) 							; on, unlocked, thawed
;			(cons 290 1) 							; Plot/No Plot : 0->No plot
;			(cons 440 "65")               			; Layer Transparency
			(cons -3	    						; transparency
				(list(list "accmtransparency"		; transparency
				(cons 1071 (LM:trans->dxf 65))	) ) ); transparency
		);end list
	);end entmake
	);end progn
	); end If 
	(CD_SHAPE)
) ;end MKLAY_INS
.
I then tried to add this code, commenting out the 'IF' statement above. This works fine except, it has an issue where the color for layer 'Insulation' is changed back to white (7)
.

Code: Select all

;Check if layer 'insulation' exists
(defun CK_LAY ()
	(if (tblsearch "layer" "Insulation")
	(CD_SHAPE)
	(MKLAY_INS)
	):END IF
);END CK_LAY
.
full lsp file attached.
CMS INTELLICAD 12.1.243.153262.PE+.VC16.x64.CMS121

i9-12900k / 64gb-3200 - NVIDIA GeForce TRX 3060 Ti 8Gb Windows 11 Pro
www.stylemarkdesigns.co.uk
Attachments
CDUCT-5.zip
(2.33 KiB) Downloaded 51 times
cron