Jump to content

Recommended Posts

Posted

I am a complete novice at lisp and this code has taken most of my spare time this week, some bits are borrowed, like the defun DTR from Afralisp site but they are obvious.

Inspired by what I have seen on here, I have the hope to automate most of my window and doors designs.

While this code is not pretty it does work and needs tweaking ( hope to work in glazing bars next).

Any observations welcome but please keep the hoots of laughter to a dull roar! :D Thanks.

 

 
(defun DTR (a) (* PI (/ a 180.0))
)
(defun C:SASH1 (/ IP P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13 P14 P15 P16 
HEIGHT WIDTH GRT GL1 GL2 RW1 BORA HEAD STILE OLDSNAP OLDBLIP OLDLIGHT)
; lisp routine to draw basic casement sash
; by Rob-GB 
(setq OLDSNAP (getvar "OSMODE")
)
(setq OLDBLIP (getvar "BLIPMODE")
)
(setq OLDLIGHT (getvar "HIGHLIGHT")
)
(setvar "CMDECHO" 0)
(setvar "BLIPMODE" 0)
(setq IP (getpoint "\nInsertion Point: "))
(setvar "OSMODE" 0)
(setq HEIGHT (getreal "\nEnter height of sash : ")
)
(setq WIDTH (getreal "\nEnter Width of sash : ")
)
(setq BORA (getreal "\nEnter Bottom Rail : ")
)
(setq HEAD (getreal "\nEnter Top Rail : ")
)
(setq STILE (getreal "\nEnter Stile : ")
)
(setq GRT (getreal "\nEnter Glass Rebate : ")
)
;Basic dims required
(setq GL1 (- HEIGHT (+(- HEAD GRT)(- BORA GRT)))
)
(setq GL2 (- WIDTH (* 2 (- STILE GRT)))
)
(setq RW1 (- WIDTH (* 2 STILE))
)
(setq P1 (POLAR IP (DTR 90.0) HEIGHT)
) ; PLOT POINTS
(setq P2 (POLAR P1 (DTR 0.0) STILE)
)
(setq P3 (POLAR P2 (DTR 0.0) RW1)
)
(setq P4 (POLAR P3 (DTR 0.0) STILE)
)
(setq P5 (POLAR P4 (DTR 270.0) HEIGHT)
)
(setq P6 (POLAR P5 (DTR 180.0) STILE)
)
(setq P7 (POLAR P6 (DTR 180.0) RW1)
)
(setq P8 (POLAR P3 (DTR 270.0) HEAD)
)
(setq P9 (POLAR P8 (DTR 180.0) RW1)
)
(setq P10 (POLAR P6 (DTR 90.0) BORA)
)
(setq P11 (POLAR P10 (DTR 180.0) RW1)
)
(setq P12 (POLAR P7 (DTR 90.0) (- BORA GRT))
)
(setq P13 (POLAR P12 (DTR 180.0) GRT)
)
(setq P14 (POLAR P13 (DTR 90.0) GL1)
)
(setq P15 (POLAR P14 (DTR 0.0) GL2)
)
(setq P16 (POLAR P15 (DTR 270.0) GL1)
)
;points plotted
(command "PLINE" IP P1 P2 P3 P4 P5 P6 P7 IP ""
); outside drawn
(command "PLINE" P2 P7 ""
)
(command "PLINE" P3 P6 ""
)
(command "PLINE" P8 P9 ""
)
(command "PLINE" P10 P11 ""
)
(command "PLINE" P13 P14 P15 P16 P13 ""
)
(setvar "OSMODE" OLDSNAP)
(setvar "BLIPMODE" OLDBLIP)
(setvar "HIGHLIGHT" OLDLIGHT)
(princ)
);defun

  • Replies 45
  • Created
  • Last Reply

Top Posters In This Topic

  • The Buzzard

    21

  • Rob-GB

    17

  • Lee Mac

    7

  • David Bethel

    1

Top Posters In This Topic

Posted Images

Posted
  Rob-GB said:
I am a complete novice at lisp and this code has taken most of my spare time this week, some bits are borrowed, like the defun DTR from Afralisp site but they are obvious.

Inspired by what I have seen on here, I have the hope to automate most of my window and doors designs.

While this code is not pretty it does work and needs tweaking ( hope to work in glazing bars next).

Any observations welcome but please keep the hoots of laughter to a dull roar! :D Thanks.

 

 

Not bad Rob-GB,

 

But I suggest you move the prompt for the insertion point after the prompts for the dimensional inputs. It would make more sense.

 

Great Job!

The Buzzard

 

(defun DTR (a) (* PI (/ a 180.0)))
(defun C:SASH1 (/ IP P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13 P14 P15 P16 
                 HEIGHT WIDTH GRT GL1 GL2 RW1 BORA HEAD STILE OLDSNAP OLDBLIP OLDLIGHT)
; lisp routine to draw basic casement sash
; by Rob-GB 
(setq OLDSNAP (getvar "OSMODE"))
(setq OLDBLIP (getvar "BLIPMODE"))
(setq OLDLIGHT (getvar "HIGHLIGHT"))
(setvar "CMDECHO" 0)
(setvar "BLIPMODE" 0)

(setvar "OSMODE" 0)
(setq HEIGHT (getreal "\nEnter height of sash : "))
(setq WIDTH (getreal "\nEnter Width of sash : "))
(setq BORA (getreal "\nEnter Bottom Rail : "))
(setq HEAD (getreal "\nEnter Top Rail : "))
(setq STILE (getreal "\nEnter Stile : "))
(setq GRT (getreal "\nEnter Glass Rebate : "))
[color=red](setq IP (getpoint "\nInsertion Point: "))  ;Move insertion point prompt here[/color]
;Basic dims required
(setq GL1 (- HEIGHT (+(- HEAD GRT)(- BORA GRT))))
(setq GL2 (- WIDTH (* 2 (- STILE GRT))))
(setq RW1 (- WIDTH (* 2 STILE)))
; PLOT POINTS
(setq P1 (POLAR IP (DTR 90.0) HEIGHT))
(setq P2 (POLAR P1 (DTR 0.0) STILE))
(setq P3 (POLAR P2 (DTR 0.0) RW1))
(setq P4 (POLAR P3 (DTR 0.0) STILE))
(setq P5 (POLAR P4 (DTR 270.0) HEIGHT))
(setq P6 (POLAR P5 (DTR 180.0) STILE))
(setq P7 (POLAR P6 (DTR 180.0) RW1))
(setq P8 (POLAR P3 (DTR 270.0) HEAD))
(setq P9 (POLAR P8 (DTR 180.0) RW1))
(setq P10 (POLAR P6 (DTR 90.0) BORA))
(setq P11 (POLAR P10 (DTR 180.0) RW1))
(setq P12 (POLAR P7 (DTR 90.0) (- BORA GRT)))
(setq P13 (POLAR P12 (DTR 180.0) GRT))
(setq P14 (POLAR P13 (DTR 90.0) GL1))
(setq P15 (POLAR P14 (DTR 0.0) GL2))
(setq P16 (POLAR P15 (DTR 270.0) GL1))
;points plotted
(command "PLINE" IP P1 P2 P3 P4 P5 P6 P7 IP ""); outside drawn
(command "PLINE" P2 P7 "")
(command "PLINE" P3 P6 "")
(command "PLINE" P8 P9 "")
(command "PLINE" P10 P11 "")
(command "PLINE" P13 P14 P15 P16 P13 "")
(setvar "OSMODE" OLDSNAP)
(setvar "BLIPMODE" OLDBLIP)
(setvar "HIGHLIGHT" OLDLIGHT)
(princ)
);defun

Posted

Hey Rob,

 

Not a bad first attempt, well done mate :)

 

A few pointers :-

 

  • I would include an error handler in the code as you are tampering with sys vars such as OSMODE and CMDECHO etc - hence if the user hits Esc, your OSnaps are going to be screwed.

  • I would include all the prompts in an IF statement, so that if the user does not input a certain entry, the routine will not error out.

  • Include "_." as a prefix to commands i.e.

 (command "_.pline"...)

 

As it will make it language and version compatible. "_" for language compatibility, and "." for if the user has redefined the function.

 

Other than that, I think it could be made more concise, but that will come in time :)

 

Good job.

 

Lee

Posted

Not bad at all.

 

In lieu of (getreal), I prefer:

 

(initget 7)
(setq var_name (getdist "\nPrompt:   "))

It forces the user to make a correct input:

(initget 7) forces an input that is not negative, non-zero and not nil

(getdist) allows pick points as well as keyboard inputs in decimal and/or the current units settings

 

-David

Posted

Thanks for the pointers guys, I will do a bit of tinkering :D.

 

Buzzard That would be more logical but I wanted to select the IP before switching off snaps. I'm only switching them off because everyone seems to do this.

 

Lee Mac I did have (command "_.line"...) in there but when I ran a test I had problems and ended up using (command "pline"...) instead and ommitting the prefix. The error handler and IF statement I shall investigate further.

 

David Bethel (initget 7) I have not come across 'till now and (getdist) I had not chosen as my blinkered thinking was all in metric as I have long since forgotten other units of measurement. This would make it more user friendly though.

 

On a side note: Does the code have to be aligned with the left margin or can the pretty zig-zag'y look work as well?

:? but :D

Posted
  Rob-GB said:

On a side note: Does the code have to be aligned with the left margin or can the pretty zig-zag'y look work as well?

:? but :D

 

the LISP interpreter (the thing that interprets what you have written into machine talk) does not care for empty space (whitespace) in the code.

 

I find it much easier to read code when it is indented, i.e.

 

(if (setq pt (getpoint "\nSelect a Point: "))
 (progn  ; <<-- Indent as IF statement isn't closed
   (setq a ...  ; <<-- Indent as Progn statement isn't closed

 

etc etc.

 

As for the getdist and initget - have a read of the Visual LISP Editor Help file in ACAD for some great info on them.

 

Lee

Posted
  Lee Mac said:
the LISP interpreter (the thing that interprets what you have written into machine talk) does not care for empty space (whitespace) in the code.

 

I find it much easier to read code when it is indented, i.e.

 

Lee

 

I kept getting " error: malformed list" type of thing so I took out all indents added a couple of )) and a missing space between a (- Height..... and it ran. So just a bit uncertain as to the real fix being any one thing or all of them.:oops:

I shall delve again into the help files, after all; it is only my insanity that keeps me going!:lol:

Posted
  Rob-GB said:
Thanks for the pointers guys, I will do a bit of tinkering :D.

 

Buzzard That would be more logical but I wanted to select the IP before switching off snaps. I'm only switching them off because everyone seems to do this.

 

Lee Mac I did have (command "_.line"...) in there but when I ran a test I had problems and ended up using (command "pline"...) instead and ommitting the prefix. The error handler and IF statement I shall investigate further.

 

David Bethel (initget 7) I have not come across 'till now and (getdist) I had not chosen as my blinkered thinking was all in metric as I have long since forgotten other units of measurement. This would make it more user friendly though.

 

On a side note: Does the code have to be aligned with the left margin or can the pretty zig-zag'y look work as well?

:? but :D

 

Then move the snap mode also, It make no sense to select an insertion point where one would expect something to be inserted imediately. Get your inputs first then select insertion point.

 

(defun DTR (a) (* PI (/ a 180.0)))
(defun C:SASH1 (/ IP P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13 P14 P15 P16 
                 HEIGHT WIDTH GRT GL1 GL2 RW1 BORA HEAD STILE OLDSNAP OLDBLIP OLDLIGHT)
; lisp routine to draw basic casement sash
; by Rob-GB 
(setq OLDSNAP (getvar "OSMODE"))
(setq OLDBLIP (getvar "BLIPMODE"))
(setq OLDLIGHT (getvar "HIGHLIGHT"))
(setvar "CMDECHO" 0)
(setvar "BLIPMODE" 0)
(setq HEIGHT (getreal "\nEnter height of sash : "))
(setq WIDTH (getreal "\nEnter Width of sash : "))
(setq BORA (getreal "\nEnter Bottom Rail : "))
(setq HEAD (getreal "\nEnter Top Rail : "))
(setq STILE (getreal "\nEnter Stile : "))
(setq GRT (getreal "\nEnter Glass Rebate : "))
[color=red](setq IP (getpoint "\nInsertion Point: "))            ;Move insertion point prompt here[/color]
[color=red](setvar "OSMODE" 0)                                   ;Snap mode moved here[/color]
;Basic dims required
(setq GL1 (- HEIGHT (+(- HEAD GRT)(- BORA GRT))))
(setq GL2 (- WIDTH (* 2 (- STILE GRT))))
(setq RW1 (- WIDTH (* 2 STILE)))
; PLOT POINTS
(setq P1 (POLAR IP (DTR 90.0) HEIGHT))
(setq P2 (POLAR P1 (DTR 0.0) STILE))
(setq P3 (POLAR P2 (DTR 0.0) RW1))
(setq P4 (POLAR P3 (DTR 0.0) STILE))
(setq P5 (POLAR P4 (DTR 270.0) HEIGHT))
(setq P6 (POLAR P5 (DTR 180.0) STILE))
(setq P7 (POLAR P6 (DTR 180.0) RW1))
(setq P8 (POLAR P3 (DTR 270.0) HEAD))
(setq P9 (POLAR P8 (DTR 180.0) RW1))
(setq P10 (POLAR P6 (DTR 90.0) BORA))
(setq P11 (POLAR P10 (DTR 180.0) RW1))
(setq P12 (POLAR P7 (DTR 90.0) (- BORA GRT)))
(setq P13 (POLAR P12 (DTR 180.0) GRT))
(setq P14 (POLAR P13 (DTR 90.0) GL1))
(setq P15 (POLAR P14 (DTR 0.0) GL2))
(setq P16 (POLAR P15 (DTR 270.0) GL1))
;points plotted
(command "PLINE" IP P1 P2 P3 P4 P5 P6 P7 IP ""); outside drawn
(command "PLINE" P2 P7 "")
(command "PLINE" P3 P6 "")
(command "PLINE" P8 P9 "")
(command "PLINE" P10 P11 "")
(command "PLINE" P13 P14 P15 P16 P13 "")
(setvar "OSMODE" OLDSNAP)
(setvar "BLIPMODE" OLDBLIP)
(setvar "HIGHLIGHT" OLDLIGHT)
(princ)
);defun

Posted

By the way, I would also want my snaps on so that I can snap to any object when inserting. You shut the snaps off before creating the sash.

 

(defun DTR (a) (* PI (/ a 180.0)))
(defun C:SASH1 (/ IP P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13 P14 P15 P16 
                 HEIGHT WIDTH GRT GL1 GL2 RW1 BORA HEAD STILE OLDSNAP OLDBLIP OLDLIGHT)
; lisp routine to draw basic casement sash
; by Rob-GB 
(setq OLDSNAP (getvar "OSMODE"))
(setq OLDBLIP (getvar "BLIPMODE"))
(setq OLDLIGHT (getvar "HIGHLIGHT"))
(setvar "CMDECHO" 0)
(setvar "BLIPMODE" 0)
[color=red](setvar "OSMODE" 575) ;Set object snap to end, mid, cen, node, qua, int and nea on[/color]
(setq HEIGHT (getreal "\nEnter height of sash : "))
(setq WIDTH (getreal "\nEnter Width of sash : "))
(setq BORA (getreal "\nEnter Bottom Rail : "))
(setq HEAD (getreal "\nEnter Top Rail : "))
(setq STILE (getreal "\nEnter Stile : "))
(setq GRT (getreal "\nEnter Glass Rebate : "))
[color=red](setq IP (getpoint "\nInsertion Point: "))            ;Move insertion point prompt here[/color]
[color=red](setvar "OSMODE" 0)                                   ;Snap mode moved here[/color]
;Basic dims required
(setq GL1 (- HEIGHT (+(- HEAD GRT)(- BORA GRT))))
(setq GL2 (- WIDTH (* 2 (- STILE GRT))))
(setq RW1 (- WIDTH (* 2 STILE)))
; PLOT POINTS
(setq P1 (POLAR IP (DTR 90.0) HEIGHT))
(setq P2 (POLAR P1 (DTR 0.0) STILE))
(setq P3 (POLAR P2 (DTR 0.0) RW1))
(setq P4 (POLAR P3 (DTR 0.0) STILE))
(setq P5 (POLAR P4 (DTR 270.0) HEIGHT))
(setq P6 (POLAR P5 (DTR 180.0) STILE))
(setq P7 (POLAR P6 (DTR 180.0) RW1))
(setq P8 (POLAR P3 (DTR 270.0) HEAD))
(setq P9 (POLAR P8 (DTR 180.0) RW1))
(setq P10 (POLAR P6 (DTR 90.0) BORA))
(setq P11 (POLAR P10 (DTR 180.0) RW1))
(setq P12 (POLAR P7 (DTR 90.0) (- BORA GRT)))
(setq P13 (POLAR P12 (DTR 180.0) GRT))
(setq P14 (POLAR P13 (DTR 90.0) GL1))
(setq P15 (POLAR P14 (DTR 0.0) GL2))
(setq P16 (POLAR P15 (DTR 270.0) GL1))
;points plotted
(command "PLINE" IP P1 P2 P3 P4 P5 P6 P7 IP ""); outside drawn
(command "PLINE" P2 P7 "")
(command "PLINE" P3 P6 "")
(command "PLINE" P8 P9 "")
(command "PLINE" P10 P11 "")
(command "PLINE" P13 P14 P15 P16 P13 "")
(setvar "OSMODE" OLDSNAP)
(setvar "BLIPMODE" OLDBLIP)
(setvar "HIGHLIGHT" OLDLIGHT)
(princ)
);defun

Posted
  Rob-GB said:
I kept getting " error: malformed list" type of thing so I took out all indents added a couple of )) and a missing space between a (- Height..... and it ran.

 

The errors will tell you a lot about what has gone wrong, and what you need to fix.

 

for example, this is how I normally interpret them:

 

malformed list  =  Missed right parenthesis ")"
extra right paren  =  Extra Right parenthesis ")"
too few arguments  =  A function doesn't have all the necessary information to run.
too many arguments  =  A function has been given too much information
bad argument type: stringp/numberp/etc =  A function has been provided with the wrong type of argument (i.e. try at the command line: (rtos "2")

 

That should be enough to point you in the right direction o:)

Posted

Thanks Buzzard. :)

 

This of course makes excellent sense if the routine allows for the (getdist) part which would benefit from snaps being on!

The fog of lisp is becoming a mere whisp (I hope).

Posted

As far as SNAP, and other sys vars go, I try to only change them as late as possible, and switch them back on as soon as possible. Meaning that without an error handler, your code is less likely to mess with the sys vars.

 

So in this case, I would:

 

(setvar "CMDECHO" 0) (setvar "OSMODE" 0)
(command "PLINE" IP P1 P2 P3 P4 P5 P6 P7 IP ""); outside drawn
(command "PLINE" P2 P7 "")
(command "PLINE" P3 P6 "")
(command "PLINE" P8 P9 "")
(command "PLINE" P10 P11 "")
(command "PLINE" P13 P14 P15 P16 P13 "")
(setvar "OSMODE" OLDSNAP)
(setvar "BLIPMODE" OLDBLIP)
(setvar "HIGHLIGHT" OLDLIGHT)
(princ)
);defun

 

As these only need to be changed for the "command" calls.

 

alternatively:

 

(mapcar 'setvar '("CMDECHO" "OSMODE") '(0 0))

 

Lee

Posted

Made another change to snap mode. See post 9.

Posted

You guys are so fast! :lol:

But your giving out some great pointers, thank you.

Posted
  The Buzzard said:
Made another change to snap mode. See post 9.

 

Buzzard, as far as Snap goes, in my opinion, other than turning it off before using a command-call, I would leave it how it is, and the user can do what they want with it, turn it on, change the settings, etc. the user may only want "nearest" on, or he/she may want all the snaps on.

 

Just my $0.02.

Posted
  Lee Mac said:
Buzzard, as far as Snap goes, in my opinion, other than turning it off before using a command-call, I would leave it how it is, and the user can do what they want with it, turn it on, change the settings, etc. the user may only want "nearest" on, or he/she may want all the snaps on.

 

Just my $0.02.

 

I understand Lee.

Just giving OP a little to think about, Thats all.

See some other possibilities.

Posted
  The Buzzard said:
I understand Lee.

Just giving OP a little to think about, Thats all.

See some other possibilities.

 

This is a subfunction of one of my earlier codes using the polar calculating method similar to your code. I did not include the dcl file or the inputs as not to confuse you with alot of additional info.

 

Please take note to the Pline command. This subfunction draws a ladder using a collar distance, ladder width, rung space, and ladder length. All points are calculated and may run over each other till the pline finally closes back to the insertion point. Another words its creating this object as one piece. Since it one piece it can be manipulated like the way you can manipulate a block when you rotate it. After the pline command you can also see the rotate command where it will prompt you for a rotation angle and rotate on insertion point. This is much better than have loose pieces of polylines. In the case such as your sash, you can rotate your sash as one piece after insertion just like a block.

 

Just a bit more to think about.

You can do so much with lisp.

 

 

;;;/////////////////////////////////////////////////////////////////
;;; Sub Function - Ladder Rack Equal To  Or Greater Then 116"          ;Describe function
;;;                But Equal To Or Less Then 120" With 9" Rung Space.
(defun LSL09120 (/ inpt pt02 pt03 pt04 pt05 pt06 pt07 pt08 pt09        ;Define function, Declare local variables
                  pt10 pt11 pt12 pt13 pt14 pt15 pt16 pt17 pt18
                  pt19 pt20 pt21 pt22 pt23 pt24 pt25 pt26 pt27
                  pt28 pt29 pt30)
 (HLR_LAYER)                                                          ;GOTO HLR_LAYER function
 (setq ladderType "LSL09120")                                         ;Change the value of variable ladderType for HLR_CONTINUE sub main function
 (setq totalColldist (- ladderLength 108.0))                          ;Calculate collar distance on both ends of ladder
 (setq collDist  (/ totalColldist 2.0))                               ;Divide the total collar distance by 2 and store in variable
 (setq inpt (getpoint "\nInsertion Point: "))                         ;Select insertion point
 (setq pt02 (polar inpt (dtr 0.0)   ladderLength))                    ;Calculate point 2
 (setq pt03 (polar pt02 (dtr 180.0) collDist))                        ;Calculate point 3
 (setq pt04 (polar pt03 (dtr 90.0)  ladderWidth))                     ;Calculate point 4
 (setq pt05 (polar pt04 (dtr 0.0)   collDist))                        ;Calculate point 5
 (setq pt06 (polar pt05 (dtr 180.0) ladderLength))                    ;Calculate point 6
 (setq pt07 (polar pt06 (dtr 0.0)   collDist))                        ;Calculate point 7
 (setq pt08 (polar pt07 (dtr 270.0) ladderWidth))                     ;Calculate point 8
 (setq pt09 (polar pt08 (dtr 0.0)   rungSpace))                       ;Calculate point 9
 (setq pt10 (polar pt09 (dtr 90.0)  ladderWidth))                     ;Calculate point 10
 (setq pt11 (polar pt10 (dtr 0.0)   rungSpace))                       ;Calculate point 11
 (setq pt12 (polar pt11 (dtr 270.0) ladderWidth))                     ;Calculate point 12
 (setq pt13 (polar pt12 (dtr 0.0)   rungSpace))                       ;Calculate point 13
 (setq pt14 (polar pt13 (dtr 90.0)  ladderWidth))                     ;Calculate point 14
 (setq pt15 (polar pt14 (dtr 0.0)   rungSpace))                       ;Calculate point 15
 (setq pt16 (polar pt15 (dtr 270.0) ladderWidth))                     ;Calculate point 16
 (setq pt17 (polar pt16 (dtr 0.0)   rungSpace))                       ;Calculate point 17
 (setq pt18 (polar pt17 (dtr 90.0)  ladderWidth))                     ;Calculate point 18
 (setq pt19 (polar pt18 (dtr 0.0)   rungSpace))                       ;Calculate point 19
 (setq pt20 (polar pt19 (dtr 270.0) ladderWidth))                     ;Calculate point 20
 (setq pt21 (polar pt20 (dtr 0.0)   rungSpace))                       ;Calculate point 21
 (setq pt22 (polar pt21 (dtr 90.0)  ladderWidth))                     ;Calculate point 22
 (setq pt23 (polar pt22 (dtr 0.0)   rungSpace))                       ;Calculate point 23
 (setq pt24 (polar pt23 (dtr 270.0) ladderWidth))                     ;Calculate point 24
 (setq pt25 (polar pt24 (dtr 0.0)   rungSpace))                       ;Calculate point 25
 (setq pt26 (polar pt25 (dtr 90.0)  ladderWidth))                     ;Calculate point 26
 (setq pt27 (polar pt26 (dtr 0.0)   rungSpace))                       ;Calculate point 27
 (setq pt28 (polar pt27 (dtr 270.0) ladderWidth))                     ;Calculate point 28
 (setq pt29 (polar pt28 (dtr 0.0)   rungSpace))                       ;Calculate point 29
 (setq pt30 (polar pt29 (dtr 90.0)  ladderWidth))                     ;Calculate point 30
 (setq pt29 (polar pt30 (dtr 270.0) ladderWidth))                     ;Calculate point 29
 (setvar "orthomode" 0)                                               ;Set orthomode to off
 (setvar "osmode" 0)                                                  ;Set object snap to off
 (command "_.Pline" inpt pt02 pt03 pt04 pt05 pt06                     ;Start pline command
                    pt07 pt08 pt09 pt10 pt11 pt12
                    pt13 pt14 pt15 pt16 pt17 pt18
                    pt19 pt20 pt21 pt22 pt23 pt24
                    pt25 pt26 pt27 pt28 pt29 pt30
                    pt29 "c")                                         ;End of pline command
 (setvar "orthomode" 1)                                               ;Set orthomode to on
 (setvar "osmode" 575)                                                ;Set object snap to end, mid, cen, node, qua, int and nea
 (prompt "\nRotation Angle: ")                                        ;Get rotation angle
 (command "_.Rotate" "last" "" inpt pause)                            ;Rotate on insertion point
 (HLR_CONTINUE)                                                       ;GOTO program HLR_CONTINUE sub main function
 (princ)                                                              ;Exit quietly
)                                                                      ;End of define function
;;;/////////////////////////////////////////////////////////////////

Posted

Here is the full program just to show you how far you can go. Please bear in mind that this code is not that good since this was one of the first code I tried to assemble. It is good enough for a demo purpose to show you what I was trying to explain to you.

 

Make sure the dcl and lsp are together and in the acad search path.

To start type HLR.

HLR.zipFetching info...

Posted

Thanks for that Buzzard, I will look through it later, I have a 380 mile round trip to do today to pick up the in-laws :cry: They're coming to stay the week so my playtime is gonna get cut. :lol:

 

Regards Rob.

Posted

Just adjusted code, been busy so had to get up early (0300hrs) and get it sorted.

 
(defun *error* (msg)
(setvar "OSMODE" *osnap)   ;error check
(setvar "CMDECHO" 1)
(princ msg)
(princ)
)
(defun DTR (a) (* PI (/ a 180.0))  ;degrees to radians
)
(defun C:SASH2 (/ IP P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13 P14 P15 P16 P17 P18 P19 P20 P21 P22 P23 
 HEIGHT WIDTH GRT GL1 GL2 RW1 BORA BRG SG HH HEAD STILE OLDSNAP OLDBLIP OLDLIGHT)
; lisp routine to draw basic casement sash v.2
; by Rob-GB 
(setq OLDSNAP (getvar "OSMODE")
)
(setq OLDBLIP (getvar "BLIPMODE")  ;store settings
)
(setq OLDLIGHT (getvar "HIGHLIGHT")
)
(setvar "CMDECHO" 0)
(setvar "BLIPMODE" 0)
(setq HEIGHT (getdist "\nEnter height of sash : ")
)
(setq WIDTH (getdist "\nEnter Width of sash : ")
)
(setq BORA (getdist "\nEnter Bottom Rail : ") ; size of rail in elevation view
)
(setq HEAD (getdist "\nEnter Top Rail : ") ; size of rail in elevation view
)
(setq STILE (getdist "\nEnter Stile : ") ; size of stile in elevation view
)
(setq GRT (getdist "\nEnter Glass Rebate : ") ; size of rebate in elevation view
)
(setq IP (getpoint "\nInsertion Point: ")) ; bottom left corner
(setvar "OSMODE" 0)
;Basic dims required
(setq GL1 (- HEIGHT (+(- HEAD GRT)(- BORA GRT)))
)
(setq GL2 (- WIDTH (* 2 (- STILE GRT)))
)
(setq RW1 (- WIDTH (* 2 STILE))
)
(setq BRG (- BORA GRT)
)
(setq SG (- STILE GRT)
)
(setq HH (- HEIGHT HEAD)
)
; PLOT POINTS
(setq P1 (POLAR IP (DTR 90.0) HEIGHT)
)     
(setq P2 (POLAR P1 (DTR 0.0) SG)
)
(setq P3 (POLAR P2 (DTR 0.0) GRT)
)
(setq P4 (POLAR P3 (DTR 0.0) RW1)
)
(setq P5 (POLAR P4 (DTR 0.0) GRT)
)
(setq P6 (POLAR P5 (DTR 0.0) SG)
)
(setq P7 (POLAR P6 (DTR 270.0) HEIGHT)
)
(setq P8 (POLAR P7 (DTR 180.0) SG)
)
(setq P9 (POLAR P8 (DTR 180.0) GRT)
)
(setq P10 (POLAR P9 (DTR 180.0) RW1)
)
(setq P11 (POLAR P10 (DTR 180.0) GRT)
)
(setq P12 (POLAR P11 (DTR 90.0) BRG)
)
(setq P13 (POLAR P12 (DTR 90.0) GL1)
)
(setq P14 (POLAR P13 (DTR 0.0) GL2)
)
(setq P15 (POLAR P14 (DTR 270.0) GL1)
)
(setq P16 (POLAR P10 (DTR 90.0) BORA)
)
(setq P17 (POLAR P10 (DTR 90.0) HH)
)
(setq P18 (POLAR P17 (DTR 0.0) RW1)
)
(setq P19 (POLAR P9 (DTR 90.0) BORA)
)
(setq P20 (POLAR P16 (DTR 270.0) GRT)
)
(setq P23 (POLAR P19 (DTR 270.0) GRT)
)
(setq P21 (POLAR P17 (DTR 90.0) GRT)
)
(setq P22 (POLAR P18 (DTR 90.0) GRT)
)
;points plotted
(command "_.PLINE" IP P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 IP ""
); outside drawn
(command "_.PLINE" P2 P11 ""
)
(command "_.PLINE" P5 P8 ""
)
(command "_.PLINE" P13 P14 ""
)
(command "_.PLINE" P12 P15 ""
)
(command "_.PLINE" P16 P17 P18 P19 P16 ""
)
(command "_.PLINE" P17 P21 ""
)
(command "_.PLINE" P18 P22 ""
)
(command "_.PLINE" P16 P20 ""
)
(command "_.PLINE" P19 P23 ""
)
(setvar "OSMODE" OLDSNAP)
(setvar "BLIPMODE" OLDBLIP)
(setvar "HIGHLIGHT" OLDLIGHT)
(princ)
);defun

 

I am a bit happier with outcome.:) It's just the organising of all the Glazing bars variants do work on now.:lol:

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