Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Create hatch- Specific scale (need help!)

Create hatch- Specific scale (need help!)

Create hatch- Specific scale (need help!)

For my company I have created a lisp that makes the placement of a custom hatch easy.
In it, the user gets to choose the hatch scale and angle by inserting the specific angle or real.
This works perfect, but I wanted to change the scale part.
I want the user to choose between three different hatchscales:
Fine (0.5), Normal (1) and Double (2)

I tried implementing this in the lisp, but cant get it to work.
Can anybody check the codes and help me out?

The code:
(defun C:HD2 (/ *error*)
(defun *error* (msg)
((or (not msg)
(member msg
'("console break"
"function cancelled"
"quit / exit abort"
((princ (strcat "\nError: " msg)))
(cond (osm (setvar "osmode" osm)))
(cond (clyr (setvar "clayer" clyr)))
(cond (ccol (setvar "cecolor" ccol)))
(cond (cpat (setvar "hpname" cpat)))
(cond (hpas (setvar "hpassoc" hpas)))
(cond (hang (setvar "hpang" hang)))
(cond (csca (setvar "hpscale" csca)))
(cond (canno (setvar "cannoscale" canno)))
(command "._-layer" "on" "*" "") ;reactivate all layers

;; local function, to create layer
(defun layer_set (lyr col ltp)
(setvar "cmdecho" 0)
(if (tblsearch "layer" lyr)
(command "._-layer" "t" lyr "u" lyr "on" lyr "s" lyr "")
(command "._-layer" "m" lyr "c" col lyr "lt" ltp lyr "")

;; main part
(setvar "cmdecho" 0) ; disable command line echo
(setq osm (getvar "osmode")) ;store osnap settings
(setq clyr (getvar "clayer")) ;store current layer
(setq csca (getvar "hpscale")) ;store current hpscale
(setq ccol (getvar "cecolor")) ; store current layer color
(setq cpat (getvar "hpname")) ; store the hatch pattern
(setq hpas (getvar "hpassoc")) ; store the hatch associativity
(setq hang (getvar "hpang")) ; store the hatch angle
(setq canno (getvar "cannoscale")) ; store cannoscale
(command "._-layer" "off" "*" "y" "on" "0,Arcering,Dakplan,Defpoints,Hekwerk,Tekst" "") ;zet alles layers uit, en vervolgens 0, defpoints,arcering, dakplan, hekwerk en tekst weer aan
(setvar "hpname" "Plat Dak,O") ; set hatch pattern to "Plat Dak"
(setvar "hpassoc" 1) ; set associativity
(layer_set "Arcering" "8" "Bylayer") ;create or set layer "Arcering" current,
;if this would not created before, then create them
; 8 - is color index of this layer, change to you suit
(setvar "osmode" 0)
(setvar "cecolor" "bylayer")
(setvar "cannoscale" "1:100") ;set annotation scale to 1:100. this is necessaity to make sure the hatch pattern "Plat Dak" displays correctly in oterh annotation scales

(setq scaleType (getkword "\nGewenste schaal: : "))
((OR (= scaleType "f") (= scaleType "F")) (setq hatchschaal 0.5) ) ;Fine scale
((OR (=scaleType "n") (= scaleType "N")) (setq hatchschaal 1) ) ;Normal scale
((OR (= scaleType "g") (= scaleType "G")) (setq hatchschaal 2) ) ;Double scale
) ;designate letters
(setq *hatchscale hatchschaal)

(if (null *hatchscale) (setq *hatchscale 1))

(setvar "hpscale" *hatchscale)



;define global variable *hatchscale
;(if (null *hatchscale) (setq *hatchscale 1))
;(if *hatchscale
; (setq #B (getreal (strcat "\nVoer arceer schaal in <"(rtos *hatchscale)">: ")))
; )
; (if #B (setq *hatchscale #B) )

; (setvar "hpscale" *hatchscale)


;define global variable *hatchangle
(if (null *hatchangle) (setq *hatchangle 0))
(if *hatchangle
(setq #A (getangle (strcat "\nSpecify hatch angle <"(rtos *hatchangle)">: ")))
(if #A (setq *hatchangle #A) )

(setvar "hpang" *hatchangle)

(setq ip (getpoint "\nPick internal point: "))
(while ip ;loop for adding multiple "internal points"
(command "-hatch" ip "AN" "y" "") ; add hatch, set annotative to YES
(setq ip (getpoint "\nPick next internal point, press to quit: "))
) ;while

(*error* nil) ;restore all saved system variables
(princ "\nStart with hv to draw hatch")

RE: Create hatch- Specific scale (need help!)

I see 1 or 2 problems, don't know if this will cure it...

Before the 'getkword' line you need an 'imnitget' statement;

(initget "F N G")

then you only need to test for capital letters but user can input lower case as well.

Near beginning you have a few lines starting with;

(cond (osm (setvar "osmode" osm)))

but should be

(cond osm (setvar "osmode" osm))

-so Lisp will treat them as variables, not functions

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close