Jump to content

Routine to set transparency 'byblock'


halam

Recommended Posts

Hi,

 

 

Wondering if any one has clue how transparency of elements in 'block' can be defined 'byblock'. Coming from Revit i have files with a overkill of blockdefinitions i just want to convert this way.

 

 

 

 

ps

 

 

I have posted a question similar in regards to mr. Gile Fixblock routine, but this doesn't seem possible back then..)

Link to comment
Share on other sites

For vanilla route it looks like group code 440 is for transparency:

 

((-1 . <Entity name: 7ff7d4c073c0>)
 (0 . "LINE")
 (330 . <Entity name: 7ff7d4c039f0>)
 (5 . "2B4")
 (100 . "AcDbEntity")
 (67 . 0)
 (410 . "Model")
 (8 . "VLD_AnnotateLINES")
 (100 . "AcDbLine")
 (10 -14.3023 -208.701 0.0)
 (11 239.348 -97.2689 0.0)
 (210 0.0 0.0 1.0)
)
_$ 
((-1 . <Entity name: 7ff7d4c073d0>)
 (0 . "LINE")
 (330 . <Entity name: 7ff7d4c039f0>)
 (5 . "2B5")
 (100 . "AcDbEntity")
 (67 . 0)
 (410 . "Model")
 (8 . "VLD_AnnotateLINES")
[color="red"] (440 . 33554572)[/color]
 (100 . "AcDbLine")
 (10 197.342 -405.725 0.0)
 (11 434.836 -405.725 0.0)
 (210 0.0 0.0 1.0)
)

 

In the above 2 line entities were compared, where one had trasparency value of 45.

Link to comment
Share on other sites

From what I understood vla-put-transperancy does NOT exist in AutoCAD, Roy.

Searched for it in various resources in vain. I would think some. Refedit, select all, command properties.

Where to start?

Edited by halam
Link to comment
Share on other sites

From what I understood vla-put-transperancy does NOT exist in AutoCAD
Try searching with the correct function name: vla-put-entitytransparency.
Link to comment
Share on other sites

Try this generic function:

; (NestedPutProp "MyBlk" 'entitytransparency "BYBLOCK")
; (NestedPutProp "MyBlk" 'color 3)
(defun NestedPutProp (nme prop val / blk)
 (if
   (and
     (not
       (vl-catch-all-error-p 
         (setq blk
           (vl-catch-all-apply
             'vla-item
             (list
               (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
               nme
             )
           )
         )
       )
     )
     (= :vlax-false (vla-get-islayout blk))
     (= :vlax-false (vla-get-isxref blk))
   )
   (vlax-for obj blk (vlax-put obj prop val))
 )
)

Link to comment
Share on other sites

Roy,

 

 

I tried it in this code. No succes. Are you sure this works on nesting? Not in my AutoCAD

A solllution would be not to apply it on 'Mytempblck' put to all blocks in the SS selection..

 

 

 



(defun C:TRBB (/ SS XS YS RA)
 (setvar "cmdecho" 0)
 (setq SS (ssget))
 (if (= XS NIL)
   (setq XS 1)
 ) ;_ end of if
 (if (= YS NIL)
   (setq YS 1)
 ) ;_ end of if
 (if (= RA NIL)
   (setq RA 0)
 ) ;_ end of if
 (command  "block"  "MytempBlk" "0,0" SS "") 
 (command  "insert"  "MytempBlk" "0,0" XS YS RA "")
 (NestedPutProp "MytempBlk" 'entitytransparency "BYBLOCK")  ; ALL blocks in SS
 (command  "explode" "l" "purge"  "b"  "MytempBlk" "n")
   
)


@Bigal

Something just like it can be found, vla-put- but i'm just don't know you to apply some code like this. .. Sorry, beyond my skills.. ;-)

 




[list=1]
[*]([url="http://www.theswamp.org/~john/avlisp/#defun"][color=#4d4dff][b]defun[/b][/color][/url] SetEntityTransparency (entity transparency [color=#008000]/[/color] typ)
[*]  ([url="http://www.theswamp.org/~john/avlisp/#if"][color=#4d4dff][b]if[/b][/color][/url] ([url="http://www.theswamp.org/~john/avlisp/#or"][color=#4d4dff][b]or[/b][/color][/url] ([url="http://www.theswamp.org/~john/avlisp/#and"][color=#4d4dff][b]and[/b][/color][/url] ([color=#008000]=[/color] 'STR ([url="http://www.theswamp.org/~john/avlisp/#setq"][color=#4d4dff][b]setq[/b][/color][/url] typ ([url="http://www.theswamp.org/~john/avlisp/#type"][color=#4d4dff][b]type[/b][/color][/url] transparency)))
[*]               ([color=#008000]=[/color] [color=#ff0000]"BYLAYER"[/color] ([url="http://www.theswamp.org/~john/avlisp/#strcase"][color=#4d4dff][b]strcase[/b][/color][/url] transparency))
[*]          )
[*]          ([url="http://www.theswamp.org/~john/avlisp/#and"][color=#4d4dff][b]and[/b][/color][/url] ([color=#008000]=[/color] 'INT typ) ([color=#008000]<=[/color] [color=#0000dd]0[/color] transparency [color=#0000dd]90[/color]))
[*]      )
[*]     ([url="http://www.theswamp.org/~john/avlisp/#cond"][color=#4d4dff][b]cond[/b][/color][/url] (([color=#008000]=[/color] '[url="http://www.theswamp.org/~john/avlisp/#vla-object"][color=#008b8b][b]VLA-OBJECT[/b][/color][/url] ([url="http://www.theswamp.org/~john/avlisp/#setq"][color=#4d4dff][b]setq[/b][/color][/url] typ ([url="http://www.theswamp.org/~john/avlisp/#type"][color=#4d4dff][b]type[/b][/color][/url] entity)))
[*]            ([url="http://www.theswamp.org/~john/avlisp/#not"][color=#4d4dff][b]not[/b][/color][/url] (vla[color=#008000]-[/color]put[color=#008000]-[/color]entitytransparency entity transparency))
[*]           )
[*]           (([color=#008000]=[/color] 'ENAME typ)
[*]            (SetEntityTransparency
[*]              (vlax[color=#008000]-[/color]ename[color=#008000]->[/color][url="http://www.theswamp.org/~john/avlisp/#vla-object"][color=#008b8b][b]vla-object[/b][/color][/url] entity)
[*]              transparency
[*]            )
[*]           )
[*]     )
[*]  )
[/list]



Edited by halam
Link to comment
Share on other sites

By the way, i notice some strange behaviour

wanting to reset "ByBlock" back to "Bylayer".. (file attached)

Is 'Transparency Byblock' supported or not ??

 

 

In BricsCAD V17 is does act normal

 

In AutoCAD 2017 with my tools it switches back to 'byblock'

In AutoCAD 2017 without any loaded lisps

In AutoCAD 2018 beta without loaded loaded

 

 

Really seems like a BUG to me..

??

 

strange transparency.dwg

Link to comment
Share on other sites

Hans if you want to change the block definitions for a selection of block references you should first extract their block names:

; (NestedPutProp "MyBlk" 'entitytransparency "BYBLOCK")
; (NestedPutProp "MyBlk" 'color 3)
(defun NestedPutProp (nme prop val / blk)
 (if
   (and
     (not
       (vl-catch-all-error-p 
         (setq blk
           (vl-catch-all-apply
             'vla-item
             (list
               (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
               nme
             )
           )
         )
       )
     )
     (= :vlax-false (vla-get-islayout blk))
     (= :vlax-false (vla-get-isxref blk))
   )
   (vlax-for obj blk (vlax-put obj prop val))
 )
)

(defun KGA_Conv_Pickset_To_ObjectList (ss / i ret)
 (if ss
   (repeat (setq i (sslength ss))
     (setq ret (cons (vlax-ename->vla-object (ssname ss (setq i (1- i)))) ret))
   )
 )
)

(defun C:TRBB ( / doc doneLst ss)
 (setq doc (vla-get-activedocument (vlax-get-acad-object)))
 (vla-endundomark doc)
 (vla-startundomark doc)
 (if (setq ss (ssget '((0 . "INSERT"))))
   (foreach obj  (KGA_Conv_Pickset_To_ObjectList ss)
     (if (not (vl-position (strcase (vla-get-name obj)) doneLst))
       (progn
         (NestedPutProp (vla-get-name obj) 'entitytransparency "BYBLOCK")
         (setq doneLst (cons (strcase (vla-get-name obj))))
       )
     )
   )
 )
 (vla-endundomark doc)
 (princ)
)

Edited by Roy_043
The doc variable was not localized.
Link to comment
Share on other sites

Thx !! that was what i was assuming...

This piece of code allready saves me a whole bunch of dead work load!

But it is still picking blocks one-by-one..

 

The final touch would be it would work on a sessies of blocks for ssget.

As reference, this tool from Gile that can do allmost all, except for the tranparency.

 

http://gilecad.azurewebsites.net/LISP/Edit_bloc_3.5.zip

 

 

Knipsel.JPG

Link to comment
Share on other sites

But it is still picking blocks one-by-one..
Judging from your last comment you have not tested the code in my previous post. If you analyse the code you will notice:

(setq ss (ssget '((0 . "INSERT"))))

Link to comment
Share on other sites

OK try this:

; (NestedPutProp "MyBlk" 'entitytransparency "BYBLOCK")
; (NestedPutProp "MyBlk" 'color 3)
(defun NestedPutProp (nme prop val / blk)
 (if
   (and
     (not
       (vl-catch-all-error-p
         (setq blk
           (vl-catch-all-apply
             'vla-item
             (list
               (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
               nme
             )
           )
         )
       )
     )
     (= :vlax-false (vla-get-islayout blk))
     (= :vlax-false (vla-get-isxref blk))
   )
   (vlax-for obj blk (vlax-put obj prop val))
 )
)

(defun KGA_Conv_Pickset_To_ObjectList (ss / i ret)
 (if ss
   (repeat (setq i (sslength ss))
     (setq ret (cons (vlax-ename->vla-object (ssname ss (setq i (1- i)))) ret))
   )
 )
)

(defun C:TRBB ( / doc doneLst ss)
 (setq doc (vla-get-activedocument (vlax-get-acad-object)))
 (vla-endundomark doc)
 (vla-startundomark doc)
 (if (setq ss (ssget '((0 . "INSERT"))))
   (foreach obj  (KGA_Conv_Pickset_To_ObjectList ss)
     (if (not (vl-position (strcase (vla-get-name obj)) doneLst))
       (progn
         (NestedPutProp (vla-get-name obj) 'entitytransparency "BYBLOCK")
         (setq doneLst (cons (strcase (vla-get-name obj)) doneLst))
       )
     )
   )
 )
 (vla-regen doc acactiveviewport)
 (vla-endundomark doc)
 (princ)
)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...