Jump to content

Hatch lisp (transparency issue)


AlexODCM

Recommended Posts

Hi,

 

I am going through our company Lisp library  to clean things up and rework old lisp's (as far as I can fix them with my basic knowledge of lisp's).

 

For the following I have reworked the following HATCH Lisp

 

How the routine looked before I got to rework on it:

 

(defun c:HRST ( )

(command "layer" "t" "LAYERNAME" "on" "LAYERNAME" "m" "LAYERNAME" "c" "COLOR" "" "")
(setvar "hpname" "ANSI37")
(setvar "hpang" 0)
(setvar "hpscale" (/ dsc 1.0))
(setvar "hpspace" (/ dsc 1.0))
(setvar "hpcolor" "bylayer")
(command "hatch")

);END DEFUN hrst

 

BTW. none of this code got past the 1ste setvar (hpname),giving message: OsMode Rejected: status nill

 

 

Reformed to something to do with our layer structure of our template,  [after I worked on it a bit]:

I stopped after number 2 because I noticed the transparency not resetting, other numbers will still be defined

 

(defun c:HRST ( / ds lfac fac hsc http htrns hcs hspc )

(setq ds (getvar "dimscale"))
    (setq lfac (getvar "dimlfac"))
    (if (= lfac 0.1)(setq fac ds))
    (if (= lfac 1)(setq fac (/ ds 1000.0)))
(setq http (getstring T "\n Give type of hatch/solid: 1=restverontreiniging, 2=GA-VDVA-hatch, 3=GA-VDVA-solid, 4=GA-GW-hatch, 5=GA-GW-solid: "))
(if (= http "1")
  (progn
    (command "layer" "n" "restverontreiniging-D25S" "m" "restverontreiniging-D25S" "c" "214" "" "")
    (command "hpname" "ANSI37")
    (command "hpang" 0)
    (command "hpcolor" "bylayer")   <--- this lead me to believe that transparancy could also be given this input "ByLayer"
    (setq htrns (getstring T "\n Give transparency (default ByLayer) [0-90]: "))
    (command "cetransparency" htrns)   <---- had to use cetransparency instead of hptransparency, because hptransparency would not set the transparency at all
    (setq hsc (* fac 1.0))
    (command "hpscale" hsc)
    (setq hspc (* fac 1.0))
    (command "hpspace" hpsc)
    (command "hatch" "" "" "")
  );end progn
);end if

(if (= http "2")
  (progn
    (command "layer" "t" "GR-GA-D15A" "o" "GR-GA-D15A" "m" "GR-GA-D15A" "c" "t" "210,174,163" "" "")
    (command "hpname" "ANSI32")
    (command "hpang" 0)
    (command "hpcolor" "bylayer")   <--- this lead me to believe that transparancy could also be given this input "ByLayer"
    (setq htrns (getstring T "\n Give transparency (default ByLayer) [0-90]: "))
    (command "cetransparency" htrns)  <---- had to use cetransparency instead of hptransparency, because hptransparency would not set the transparency at all
    (setq hsc (* fac 1.0))
    (command "hpscale" hsc)
    (setq hspc (* fac 1.0))
    (command "hpspace" hpsc)
    (command "hatch" "" "" "")
  );end progn
);end if
);END DEFUN hrst

 

But when testing I notice that my transparency for new hatches/lines/circles/.... is also set to 25 transparency after this routine.

I tried fixing this with wirting a line before the );END DEFUN for resetting:

- (command "cetransparency"  "0")  <---- not the best sollution as this does not set it back to "ByLayer"

- (command "cetransparency"  "bylayer")

- (command "cetransparency"  "byl")

- (setvar "cetransparency"  "0")  <---- not the best sollution as this does not set it back to "ByLayer"

- (setvar "cetransparency"  "bylayer")

- (setvar "cetransparency"  "byl")

 

I can go through the routine and it does everything I've set up to do so, except keeping the cetransparency the value given in the routine.

Rather than resetting it to the default ByLayer

 

But after looking through forums a lot of questions for BLOCKS hatch edits but not about single hatch transaprency variabels.

 

Could someone help me out and also explain what I am doing wrong if possible for learning more about the process.

 

Thanks in advance!

 

 

 

Edited by AlexODCM
wierd text formatting
Link to comment
Share on other sites

OK. Don't know if this will help but on first look through I picked this up :

 

System Variable Schpiel :

 

HPTRANSPARENCY
Sets the default transparency for new hatches and fills.

Valid values include "use current" or ".", ByLayer, ByBlock, and integer values from 0 to 90. The higher the value the more transparent the hatch.

Values other than "use current" or "." value override the current transparency, CETRANSPARENCY.

Changing this value does not affect existing hatch objects.

 

CETRANSPARENCY

Sets the transparency level for new objects.

ByLayer (-1)        Transparency value determined by layer
ByBlock (-2)        Transparency value determined by block
0            Fully opaque (not transparent)
1-90        Transparency value defined as a percentage

 

To change the transparency of existing objects, use the Properties palette or the Layer Properties Manager.

Note: Transparency is limited to 90 percent to avoid confusion with layers that are turned off or frozen.

The transparency level for new hatch objects is controlled by the HPTRANSPARENCY system variable.

 

So it would seem that the only strings you could pass to HPTRANSPARENCY are "use current" or "." You could also pass the AutoCAD constant symbols ByLayer & ByBlock (values given in CETRANSPARENCY) or an integer

 

This is your code. What is the entity type (string, integer, float)  you are passing to cetransparency/hptransparency?

 (setq htrns (getstring T "\n Give transparency (default ByLayer) [0-90]: "))
 (command "cetransparency" htrns)

 

Edited by dlanorh
Link to comment
Share on other sites

On 7/25/2020 at 7:09 PM, Roy_043 said:

Have you tried using "ByLayer" instead of "bylayer" (for both variables)?

I have tried this indeed, the transparrancy of new command set everything on 25 transparancy instead only the created hatch.

Link to comment
Share on other sites

On 7/25/2020 at 7:14 PM, dlanorh said:

OK. Don't know if this will help but on first look through I picked this up :

 

System Variable Schpiel :

 

HPTRANSPARENCY
Sets the default transparency for new hatches and fills.

Valid values include "use current" or ".", ByLayer, ByBlock, and integer values from 0 to 90. The higher the value the more transparent the hatch.

Values other than "use current" or "." value override the current transparency, CETRANSPARENCY.

Changing this value does not affect existing hatch objects.

 

CETRANSPARENCY

Sets the transparency level for new objects.

ByLayer (-1)        Transparency value determined by layer
ByBlock (-2)        Transparency value determined by block
0            Fully opaque (not transparent)
1-90        Transparency value defined as a percentage

 

To change the transparency of existing objects, use the Properties palette or the Layer Properties Manager.

Note: Transparency is limited to 90 percent to avoid confusion with layers that are turned off or frozen.

The transparency level for new hatch objects is controlled by the HPTRANSPARENCY system variable.

 

So it would seem that the only strings you could pass to HPTRANSPARENCY are "use current" or "." You could also pass the AutoCAD constant symbols ByLayer & ByBlock (values given in CETRANSPARENCY) or an integer

 

This is your code. What is the entity type (string, integer, float)  you are passing to cetransparency/hptransparency?  


 (setq htrns (getstring T "\n Give transparency (default ByLayer) [0-90]: "))
 (command "cetransparency" htrns)

The goal of the lisp is to use our housestyle layers and colors for al of our employees when hatching.

 

Those 2 definitions of the commands are not helping as the code is using the command.

 

The lisp works great as far as the transparency still staying at the given value after the command or not changing when using "hptransparency"

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...