Jump to content

Recommended Posts

Posted

Could some one help me with calculation for lips routine

here's what i've got so far any help will be great.

I tried to break down formula as much as i could to make it easy for programming.

area of orifice.lsp

untitled.jpg

Posted

I don't that I grasp the entire process, but here is a better starting point:

 

[b][color=BLACK]([/color][/b]defun c:orifice [b][color=FUCHSIA]([/color][/b]/ q1 hl g oa od[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]initget 7[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]setq q1 [b][color=NAVY]([/color][/b]getreal [color=#2f4f4f]"\nQ1 Data:   "[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]initget 7[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]setq hl [b][color=NAVY]([/color][/b]getreal [color=#2f4f4f]"\nHL Data:   "[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]initget 7[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]setq g [b][color=NAVY]([/color][/b]getreal [color=#2f4f4f]"\nG Data:   "[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

[color=#8b4513];;;ORIFICE AREA[/color]
 [b][color=FUCHSIA]([/color][/b]setq oa [b][color=NAVY]([/color][/b]/ q1 [b][color=MAROON]([/color][/b]* 0.61 [b][color=GREEN]([/color][/b]sqrt [b][color=BLUE]([/color][/b]* 2 g hl[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

[color=#8b4513];;;;I DONT UNDERSTAND THE MIDDLE 2 STATEMENTS[/color]

[color=#8b4513];;;ORIFICE DIAMETER[/color]
 [b][color=FUCHSIA]([/color][/b]setq od [b][color=NAVY]([/color][/b]* 2 [b][color=MAROON]([/color][/b]sqrt [b][color=GREEN]([/color][/b]/ 0.001671 pi[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

-David

Posted

looks good thanks real clean.

this, language can really work huh .

this will help development for sure.

i enjoy lisp but am not sure how to use vbaide.

thanks again

Posted

Lee,

 

1 (bit 0) Prevents the user from responding to the request by entering only ENTER.

2 (bit 1) Prevents the user from responding to the request by entering zero.

4 (bit 2) Prevents the user from responding to the request by entering a negative value.

 

 

1 + 2 + 4 = 7

 

It forces a positive numeric input. -David

Posted

Thanks David for your info,

 

I have improved on your routine slightly: (hopefully this is what JON is after!)

 

(defun c:orifice (/ g q1 hl oa od)
   (or g (setq g 9.81))
   (initget 7)
   (setq q1 (getreal "\nQ1 Data:   "))
   (initget 7)
   (setq hl (getreal "\nHL Data:   "))
   (initget 6)
   (or
   (setq g (getreal (strcat "\nG Data <" (rtos g) "> : ")))
   (setq g 9.81)
   ) ;_  end or
   (setq oa (/ q1 (* 0.61 (sqrt (* 2 g hl)))))
   (setq od (* 2 (sqrt (/ oa pi))))
   (princ (strcat "Orifice Area: "
          (rtos oa)
          "\nOrifice Diameter: "
          (rtos od)
      ) ;_  end strcat
   ) ;_  end princ
   (prin1)
) ;_  end defun

Posted
Lee,

 

1 (bit 0) Prevents the user from responding to the request by entering only ENTER.

2 (bit 1) Prevents the user from responding to the request by entering zero.

4 (bit 2) Prevents the user from responding to the request by entering a negative value.

 

 

1 + 2 + 4 = 7

 

It forces a positive numeric input. -David

Continuing of lee mac's comment.

Is their any other bits?

or just the 3?

Posted

I'm not worthy of such Genius .

Posted

"Continuing of lee mac's comment.

Is their any other bits?

or just the 3?"

 

Yes quite a few, see AutoCAD help>>Customization Guide>>etc,,...Autolisp reference.

 

Under "initget" you'll find discussion for 10 bits or so.

Posted

 


  (or g (setq g 9.81))

(    (initget 6)
   (or
   (setq g (getreal (strcat "\nG Data <" (rtos g) "> : ")))
   (setq g 9.81)
   ) ;_  end or

 

Lee,

Try this for nil inputs

(initget 6)
(setq g (getreal "\nG Data <9.81>:   "))
(and (not g)
    (setq g 9.81))

-David

Posted

Hi David,

 

thanks for your reply,

 

The reason I formatted it that was was that I was initially going to use a "SETENV" statement, so that the variable would hold its value outside of the routine, so that the routine would remember the last value entered and not just 9.81.

Posted

Like this:

 

(defun c:orifice (/ g q1 hl oa od)
   (or (getenv "ORIF:g") (setenv "ORIF:g" "9.81"))
   (initget 7)
   (setq q1 (getreal "\nQ1 Data:   "))
   (initget 7)
   (setq hl (getreal "\nHL Data:   "))
   (initget 6)
   (if    (setq g (getreal (strcat "\nG Data <" (getenv "ORIF:g") "> : ")))
   (setenv "ORIF:g" (rtos g))
   ) ;_  end if
   (setq oa (/ q1 (* 0.61 (sqrt (* 2 (atof (getenv "ORIF:g")) hl)))))
   (setq od (* 2 (sqrt (/ oa pi))))
   (princ (strcat "Orifice Area: "
          (rtos oa)
          "\nOrifice Diameter: "
          (rtos od)
      ) ;_  end strcat
   ) ;_  end princ
   (prin1)
) ;_  end defun

Posted

Lee,

 

The ( getenv ) & ( setenv ) calls were originally used to set and read a DOS environment SET values. It was very limited in that DOSs environment size was preset and very limited in size.

 

I think that the way you are using it will bloat someones registry over a period of time and they have no way cleaning it out. My $0.02 -David

Posted

Ahhh, thanks David for the $0.02, didn't know 'bout that minor issue....

 

How does one get rid of a (setenv) value if created then? or can't you?

Posted

Lee,

 

I guess if you reset the value to "" and then ran a registry cleaner program, it might be able to remove the key. I'd give it a 50/50 chance. -David

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