Author Topic: How would you array this horizotally  (Read 7556 times)

0 Members and 1 Guest are viewing this topic.

One Shot

  • Guest
How would you array this horizotally
« on: May 08, 2008, 02:17:23 PM »
How would you get this to array horizontally to have a choice of a overhange of a window opening of (0" & 3 3/16") at Top Left and Top Right corner of a opening.  Plus have the Joint adjust between 1/4" to no more than 1/2" to work equally?

This code is a test Soldier Course.  This is the easist to do first.

Code: [Select]
(defun C:SC-Test()         
         
          (setq oldsnap (getvar "osmode"))
          (setvar "osmode" 0)
          (setq oldblip (getvar "blipmode"))
          (setvar "blipmode" 0)
          (setq width 3.625)
          (setq height 7.250)
          (setq cheight 7.625)
          (setq jt 0.375)
          (setq pt1 (getpoint "\nPick point top left corrner of opening: "))
          (setvar "osmode" 0)   
          (setq pt2 (polar pt1 0 width))
          (setq pt3 (polar pt2 (* pi 0.5) height))
          (setq pt4 (polar pt3 pi width))
          (command "pline" pt1 pt2 pt3 pt4 pt1 "")
          (setq br (entlast))


Thank you for you help with this.

Brad

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How would you array this horizotally
« Reply #1 on: May 08, 2008, 05:47:13 PM »
Brad,
How about a picture or a DWG to go with your explanation?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

One Shot

  • Guest
Re: How would you array this horizotally
« Reply #2 on: May 08, 2008, 07:02:57 PM »
Sorry about that that.  I had this at home when I posted this thread today.

Adesu

  • Guest
Re: How would you array this horizotally
« Reply #3 on: May 08, 2008, 09:43:51 PM »
Hi Brad,
Do you mean like this
Code: [Select]
(defun C:SC-Test(/ br cheight height jt oldsnap pt1 pt2 pt3 pt4 width)
  (setq oldsnap (getvar "osmode"))
  (setvar "osmode" 0)
  (setq oldsnap (getvar "blipmode"))
  (setvar "blipmode" 0)
  (setq width 3.625)
  (setq height 7.250)
  (setq cheight 7.625)
  (setq jt 0.375)
  (setq pt1 (getpoint "\nPick point top left corrner of opening: "))
  (setvar "osmode" 0)
  (setq pt2 (polar pt1 0 width))
  (setq pt3 (polar pt2 (* pi 0.5) height))
  (setq pt4 (polar pt3 pi width))
  (command "pline" pt1 pt2 pt3 pt4 pt1 "")
  (setq br (entlast))
  (command "_array" br "" "r" 1 10 4 "")
  (setvar "osmode" oldsnap)
  (setvar "blipmode" oldsnap)
  (princ)
  ) ; defun 

How would you get this to array horizontally to have a choice of a overhange of a window opening of (0" & 3 3/16") at Top Left and Top Right corner of a opening.  Plus have the Joint adjust between 1/4" to no more than 1/2" to work equally?

This code is a test Soldier Course.  This is the easist to do first.

Code: [Select]
(defun C:SC-Test()         
         
          (setq oldsnap (getvar "osmode"))
          (setvar "osmode" 0)
          (setq oldblip (getvar "blipmode"))
          (setvar "blipmode" 0)
          (setq width 3.625)
          (setq height 7.250)
          (setq cheight 7.625)
          (setq jt 0.375)
          (setq pt1 (getpoint "\nPick point top left corrner of opening: "))
          (setvar "osmode" 0)   
          (setq pt2 (polar pt1 0 width))
          (setq pt3 (polar pt2 (* pi 0.5) height))
          (setq pt4 (polar pt3 pi width))
          (command "pline" pt1 pt2 pt3 pt4 pt1 "")
          (setq br (entlast))


Thank you for you help with this.

Brad

One Shot

  • Guest
Re: How would you array this horizotally
« Reply #4 on: May 08, 2008, 10:13:01 PM »
Hi Adesu,

Thank you for that.  Did you by chance look at the drawing file that is attached to this thread?  Tomorrow I will be working on the other pick point so that I could pick another point and the brick continues to that point.  I will be also working on the Mortar joint also.

Thank you very much for the help.

Brad

Hi Brad,
Do you mean like this
Code: [Select]
(defun C:SC-Test(/ br cheight height jt oldsnap pt1 pt2 pt3 pt4 width)
  (setq oldsnap (getvar "osmode"))
  (setvar "osmode" 0)
  (setq oldsnap (getvar "blipmode"))
  (setvar "blipmode" 0)
  (setq width 3.625)
  (setq height 7.250)
  (setq cheight 7.625)
  (setq jt 0.375)
  (setq pt1 (getpoint "\nPick point top left corrner of opening: "))
  (setvar "osmode" 0)
  (setq pt2 (polar pt1 0 width))
  (setq pt3 (polar pt2 (* pi 0.5) height))
  (setq pt4 (polar pt3 pi width))
  (command "pline" pt1 pt2 pt3 pt4 pt1 "")
  (setq br (entlast))
  (command "_array" br "" "r" 1 10 4 "")
  (setvar "osmode" oldsnap)
  (setvar "blipmode" oldsnap)
  (princ)
  ) ; defun 

How would you get this to array horizontally to have a choice of a overhange of a window opening of (0" & 3 3/16") at Top Left and Top Right corner of a opening.  Plus have the Joint adjust between 1/4" to no more than 1/2" to work equally?

This code is a test Soldier Course.  This is the easist to do first.

Code: [Select]
(defun C:SC-Test()         
         
          (setq oldsnap (getvar "osmode"))
          (setvar "osmode" 0)
          (setq oldblip (getvar "blipmode"))
          (setvar "blipmode" 0)
          (setq width 3.625)
          (setq height 7.250)
          (setq cheight 7.625)
          (setq jt 0.375)
          (setq pt1 (getpoint "\nPick point top left corrner of opening: "))
          (setvar "osmode" 0)   
          (setq pt2 (polar pt1 0 width))
          (setq pt3 (polar pt2 (* pi 0.5) height))
          (setq pt4 (polar pt3 pi width))
          (command "pline" pt1 pt2 pt3 pt4 pt1 "")
          (setq br (entlast))


Thank you for you help with this.

Brad

Fatty

  • Guest
Re: How would you array this horizotally
« Reply #5 on: May 09, 2008, 06:40:12 AM »
I have just a few minutes to write the code,
follow this way further :-)

Code: [Select]
            (defun C:SC-Test  (/ cheight cpt gpt1 gpt2 gpt3 gpt4 height jt num
         oldblip oldsnap pt1 pt2 pt3 pt4 ss step width)
    (setvar "cmdecho" 0)
    (setq oldsnap (getvar "osmode"))
    (setvar "osmode" 0)
    (setq oldblip (getvar "blipmode"))
    (setvar "blipmode" 0)
    (setq width 3.625)
    (setq height 7.250)
    (setq cheight 3.625);<-- change to suit
    (setq jt 0.375)
    (setq pt1 (getpoint "\nPick point top left corner of opening: "))
    (setq pt2 (polar pt1 0 width))
    (setq pt3 (polar pt2 (* pi 0.5) height))
    (setq pt4 (polar pt3 pi width))
    (command "pline")
    (apply 'command (list pt1 pt2 pt3 pt4 pt1))
    (command "CL") ;<--closed pline
    (command "extrude" "L" "" cheight)
    (setq step (+ jt width))
    (setq num (getint "\nNumber of bricks in the row: "))
    (command "-array" (ssget "L") "" "R" 1 num step)
    (setq gpt1 pt2
  gpt2 (list (car gpt1) (- (cadr gpt1) width) (caddr pt1))
  gpt3 (list (+ (car gpt2) jt) (cadr gpt2) (caddr pt1))
  gpt4 (list (car gpt3) (cadr gpt1) (caddr pt1))
  cpt  (list (+ (car gpt2) (/ jt 2.0)) (cadr gpt2) (caddr pt1))
  )
    (command "pline")
    (apply 'command (list gpt3 gpt4 gpt1 gpt2))
    (command) ;<--opened pline
    (setq ss (ssadd))
    (ssadd (entlast) ss)
    (command "arc" "C" "none" cpt "none" gpt3 "none" gpt2)
    (ssadd (entlast) ss)
    (setvar "peditaccept" 1)
    (command "pedit" "m" ss "" "J" "" "" "")
    (if (not (arxload "geom3d.arx"))
        (arxload "geom3d.arx")
      )
    (command "extrude" "L" "" height)
    (command "rotate3D" "L" "" "X" gpt1 -90.0)
    (arxunload "geom3d.arx")
    (command "-array" (ssget "L") "" "R" 1 (1- num) step)
    (setvar "osmode" oldsnap)
    (setvar "blipmode" oldblip)
    (setvar "cmdecho" 1)
    (princ)
    )

~'J'~

One Shot

  • Guest
Re: How would you array this horizotally
« Reply #6 on: May 09, 2008, 10:41:17 AM »
How did I do with this.  I got an error message.

Code: [Select]
(defun C:SCJT-Test(/ jt jheight height oldsnap jpt1 jpt2 jpt3 jpt4 jpt5 jpt6 jpt7 jpt8 jpt9 jpt10 jpt11 jpt12 width)
  (setq oldsnap (getvar "osmode"))
  (setvar "osmode" 0)
  (setq oldsnap (getvar "blipmode"))
  (setvar "blipmode" 0)
  (setq width 0.375)
  (setq jheight 7.625)
  (setq jt 0.375)
  (setq jjpt1 (getpoint "\nPick point top left corrner of opening: "))
  (setvar "osmode" 0)
  (setq jpt2 (polar jpt1 0 width))
  (setq jpt3 (polar jpt2 (* pi 0.5) height))
  (setq jpt4 (polar jpt3 pi width))
  (setq jpt5 (polar jpt4 pi width))
  (setq jpt6 (polar jpt5 (* pi 0.5) height))
  (setq jpt7 (polar jpt6 pi width))
  (setq jpt8 (polar jpt7 pi width))
  (setq jpt9 (polar jpt8 (* pi 0.5) height))
  (setq jpt10(polar jpt9 pi width))
  (setq jpt11(polar jpt10 (* pi 0.5) height))
  (setq jpt12(polar jpt11 pi width))
  (command "pline" jpt1 jpt2 jpt3 jpt4 jpt5 jpt6 jpt7 jpt8 jpt9 jpt10 jpt11 jpt12 jpt1 "")
  (command "extrude" "L" "" height)
  (arxunload "geom3d.arx")
  (setvar "osmode" oldsnap)
  (setvar "blipmode" oldblip)
  (setvar "cmdecho" 1)
  (princ)
  )


deegeecees

  • Guest
Re: How would you array this horizotally
« Reply #7 on: May 09, 2008, 02:08:34 PM »
You're not setting some variables that you are referencing, for starters.

daron

  • Guest
Re: How would you array this horizotally
« Reply #8 on: May 09, 2008, 03:16:15 PM »
For starters, this:
Code: [Select]
(setq oldsnap (getvar "osmode"))
  (setvar "osmode" 0)
  (setq oldsnap (getvar "blipmode"))[color=red];Sorry Brad, this was Adesu's mistake, not yours. I just now saw that.[/color]
  (setvar "blipmode" 0)
...
  (setvar "osmode" 0)
...
  (setvar "osmode" oldsnap)
  (setvar "blipmode" oldblip)
  (setvar "cmdecho" 1)
the variable oldnanap gets set as the value for osmode, then you proceed to set osmode to 0 and replace blipmode's value to the variable oldsnap. Now the value for oldsnap is either 1 or 0. Further down the line, without having changed osmode from 0, you change it to 0 again. Then at the bottom, you are changing osmode again to a value derived from blipmode, which is 0 or 1, so depending on what was set, you'll either end up with no running snaps or endpoint. Finally, oldblip was never created and I think what DGC is referring to and then you hard set cmdecho to 1. I see it as just an oversight, but it appears you meant to set blipmode to oldblip. Also, you'll want to get the value for cmdecho in a variable in the beginning and then turn it off if that is what you so desire, then return to the original value when you're done, not hard code it.
« Last Edit: May 09, 2008, 04:08:30 PM by Daron »

deegeecees

  • Guest
Re: How would you array this horizotally
« Reply #9 on: May 09, 2008, 03:24:54 PM »
(setq jpt3 (polar jpt2 (* pi 0.5) height))

This variable needs to be set, or take the "j" off in this line:

(setq jheight 7.625)

deegeecees

  • Guest
Re: How would you array this horizotally
« Reply #10 on: May 09, 2008, 03:26:49 PM »
O.T....   7.625 is the diameter of an M16 round if I remember correctly.   :wink:

daron

  • Guest
Re: How would you array this horizotally
« Reply #11 on: May 09, 2008, 03:27:39 PM »
Seriously, you can tidy it all up by
Code: [Select]
(setq sysvaris
     (mapcar
          '(lambda (x)
               (cons x (getvar x))
           )
           (list "osmode" "blipmode" "cmdecho")
     )
)
You'll end up with a list that looks like:
Code: [Select]
(("osmode" . 6239) ("blipmode" . 0) ("cmdecho" . 1))You can then change any value any way you want except sysvaris and when you're done call:
Code: [Select]
(mapcar '(lambda (x) (setvar (car x) (cdr x))) sysvaris)This is essentially some code I gave you before, but set to be able to be contained directly inside you routine. If you want to add more variables, just add them to the list in the sysvaris variable. If you do this, you will not have the problem described above and your code will look a lot cleaner IMO and be easier to maintain. If you don't understand how or why it's working, just ask. Once you understand how mapcar and cons work, many more ideas will crop up. If you don't like it, let me know. I'd also like a reason as to why, though.
« Last Edit: May 09, 2008, 03:42:53 PM by Daron »

Fatty

  • Guest
Re: How would you array this horizotally
« Reply #12 on: May 09, 2008, 03:59:01 PM »
Hi, mate
First of all change jjpt1 on jpt1 and height on jheight
Then you need to draw the polyline to be extruded
correctly, because of in you code this was drawn as
a self-intersected and you should't to extrude this
contour
Attach the sample picture of this polyline you want
to create
[And also I'm still avoid to use polar function for
parametric drafting (IMO only)]

~'J'~

One Shot

  • Guest
Re: How would you array this horizotally
« Reply #13 on: May 09, 2008, 04:07:45 PM »
O.T....   7.625 is the diameter of an M16 round if I remember correctly.   :wink:

The M16A1 uses a 5.56 mm NATO round .
The M60, M14, AK47, 7.625mm Nato round.

One Shot

  • Guest
Re: How would you array this horizotally
« Reply #14 on: May 09, 2008, 04:10:02 PM »
Hi, mate
First of all change jjpt1 on jpt1 and height on jheight
Then you need to draw the polyline to be extruded
correctly, because of in you code this was drawn as
a self-intersected and you should't to extrude this
contour
Attach the sample picture of this polyline you want
to create
[And also I'm still avoid to use polar function for
parametric drafting (IMO only)]



~'J'~

I think you forgot to attach the picture.

Thank you,

Brad

daron

  • Guest
Re: How would you array this horizotally
« Reply #15 on: May 09, 2008, 04:19:47 PM »
Code: [Select]
(arxunload "geom3d.arx")Okay, I see it now. You're taking bits and pieces and trying to put them together. That bit is from fatty, but in the code you posted since, the reason for it is missing. Step through the code piece by piece in the vlide. You'll quickly find the mistakes. Also, to make life easy on you you can group things like:
Code: [Select]
 (setq width 3.625
        height 7.250
        cheight 7.625
  )
It also works with command, but I like the way fatty used apply in this case. It doesn't work on setvar, which is why I came up with my functions listed above.


Just some pointers to help you along. I see that you have a long road ahead of you with a couple of items you've decided to take on. If you learn good practices now, it'll save you later.

Hi, mate
First of all change jjpt1 on jpt1 and height on jheight
Then you need to draw the polyline to be extruded
correctly, because of in you code this was drawn as
a self-intersected and you should't to extrude this
contour
Attach the sample picture of this polyline you want
to create
[And also I'm still avoid to use polar function for
parametric drafting (IMO only)]



~'J'~

I think you forgot to attach the picture.

Thank you,

Brad

I think he's asking you to attach something, but I could be wrong.

Fatty

  • Guest
Re: How would you array this horizotally
« Reply #16 on: May 09, 2008, 04:53:39 PM »
Ah, you know, I'm absolutely dumb in English grammar
Yes, I want to see the shape you need to extrude,
let you attach the picture here
Sorry again for my poor english :oops:

~'J'~

One Shot

  • Guest
Re: How would you array this horizotally
« Reply #17 on: May 09, 2008, 07:54:30 PM »
Ah, you know, I'm absolutely dumb in English grammar
Yes, I want to see the shape you need to extrude,
let you attach the picture here
Sorry again for my poor english :oops:

~'J'~


Fatty,

please the attachment for the step that this lisp would take plus final application.  Please look in Model space and in the paper Space Tab.

Fatty

  • Guest
Re: How would you array this horizotally
« Reply #18 on: May 10, 2008, 12:21:39 AM »
Much better
I'll try :)

~'J'~

Fatty

  • Guest
Re: How would you array this horizotally
« Reply #19 on: May 10, 2008, 05:12:00 AM »
Give this a shot

Code: [Select]
(defun C:try  (/      brick  cheight    cnt   diff dist height joint  jp1    jp10   jp11   jp12   jp2 jp3
       jp4    jp5    jp6    jp7    jp8   jp9 leng lp     mark   mjoin  mp1    mp2    num   overhang
       p1     p2     ptlist response   rp sjoint step   width  x      y)

  (command "._undo" "_BE")
  (setvar "osmode" 0)
  (setvar "cmdecho" 0)
  (setq width 2.25
height 7.625
cheight 3.625
overhang 3.25
joint 0.375)
  (setvar "orthomode" 1)
  (setq lp (getpoint "\nPick point top left corrner of opening: ")
rp (getpoint lp "\nPick point top right corrner of opening: ")
)
  (initget "Yes No")
  (setq response (getkword
   "\nIs there an overhang beyond the opening or no opening?\n (Yes/No) <Y>: "))
  (if (not response)
    (setq response "Yes"))
  (if (eq "Yes" response)
    (progn
      (setq mark T)
      (setq lp (list (- (car lp) overhang) (cadr lp))
    rp (list (+ (car rp) overhang) (cadr rp))
    )
      )
    (setq mark nil)
    )

  (setq dist (distance (trans lp 0 1) (trans rp 0 1)))
  (setq cnt (fix (/ dist width)))
  (setq leng (* cnt width))
  (setq diff (- dist leng))

  (if (< diff 0)
    (progn
      (setq cnt (1- cnt))
      (setq leng (* cnt width))
      (setq diff (- dist leng))))
  (setq mjoin (/ diff (1- cnt)))
  (alert (vl-princ-to-string cnt))
  ;; recalculate till the joint will have a desired size :
  (while (< mjoin 0.25)
    (progn
      (setq cnt (1- cnt))
      (setq leng (* cnt width))
      (setq diff (- dist leng)))
    (setq mjoin (/ diff (1- cnt))))
  (setq leng (+ (* cnt width) (* (1- cnt) mjoin)))

  ;; compare result with length of opening 
  (if (not (equal leng dist 0.001))
    (progn
      (princ "\nWrong result, you're the dumb, Fatty")
      (exit)
      (princ)
      )
    )
  ;; get the step of an array 
  (setq step (+ width mjoin))

  ;; draw a single brick
  (setq p1 (list (car lp) (cadr lp))
p2 (list (+ (car lp) width) (+ (cadr lp) height))
)

  (command "._zoom" "_W" p1 p2)
  (setvar "clayer" "0")
  (setvar "cecolor" "22")
  (command "._rectang" p1 p2)
  (command "extrude" "L" "" cheight)
  ;; array 
  (setq brick (entlast))
  (command "-array" brick "" "R" "" (itoa cnt) (rtos step))

  ;; draw a single joint
  (setq mp1 (list (car p2) (cadr p1))
mp2 (list (+ (car p2) mjoin) (cadr p2))
)
  (setvar "cecolor" "9")
  (command "._rectang" mp1 mp2)
  (command "extrude" "L" "" cheight)
  ;; array   
  (setq sjoint (entlast))
  (command "-array"
   sjoint
   ""
   "_R"
   ""
   (itoa (1- cnt))
   (rtos step))

  ;; draw mortar joint by style

  (if (not mark) ; without overhangs
    (progn
      (setq jp1 lp
    jp2 (list (car lp) (+ (cadr lp) height))
    jp3 (list (car rp) (cadr jp2))
    jp4 (list (car jp3) (cadr jp1))
    jp5 (list (+ (car jp4) joint) (cadr jp4))
    jp6 (list (car jp5) (+ (cadr jp3) joint))
    jp7 (list (- (car jp1) joint) (cadr jp6))
    jp8 (list (car jp7) (cadr jp1))
    )

      (setq ptlist (list jp1 jp2 jp3 jp4 jp5 jp6 jp7 jp8))
      (entmake
(append
  (list
    '(0 . "LWPOLYLINE")
    '(100 . "AcDbEntity")
    '(8 . "0")
    '(100 . "AcDbPolyline")
    (cons 90 (length ptlist)) ;number of verticies
    (cons 70 1) ;closed
    (cons 62 9) ; color
    (cons 43 0.0) ;constant width
    )
  (mapcar '(lambda (x) (cons 10 x)) ptlist))

)
      (command "extrude" "L" "" cheight)
      )
                                  ;; with overhangs
    (progn
      (setq jp1 lp
    jp2 (list (car lp) (+ (cadr lp) height) (caddr lp))
    jp3 (list (car rp) (cadr jp2) (caddr lp))
    jp4 (list (car jp3) (cadr jp1) (caddr lp))
    jp5 (list (- (car jp4) overhang) (cadr jp4) (caddr lp))
    jp6 (list (car jp5) (- (cadr jp5) joint) (caddr lp))
    jp7 (list (+ (car rp) joint) (cadr jp6) (caddr lp))
    jp8 (list (car jp7) (+ (cadr jp5) joint height) (caddr lp))
    jp9 (list (- (car lp) joint) (cadr jp8) (caddr lp))
    jp10 (list (car jp9) (cadr jp6) (caddr lp))
    jp11 (list (+ (car jp1) overhang) (cadr jp6) (caddr lp))
    jp12 (list (car jp11) (cadr jp5) (caddr lp))
    )

      (setq ptlist (list jp1 jp2 jp3 jp4 jp5 jp6 jp7 jp8 jp9 jp10 jp11 jp11 jp12))
      (entmake
(append
  (list
    '(0 . "LWPOLYLINE")
    '(100 . "AcDbEntity")
    '(8 . "0")
    '(100 . "AcDbPolyline")
    (cons 90 (length ptlist)) ;number of verticies
    (cons 70 1) ;closed
    (cons 62 9) ; color
    (cons 43 0.0) ;constant width
    )
  (mapcar '(lambda (x) (cons 10 x))
  (mapcar '(lambda (y) (list (car y) (cadr y))) ptlist))
  )
)
      (command "extrude" "L" "" cheight)
      )
    )
  (command "._zoom" "_P")
  (setvar "osmode" 0)
  (setvar "cmdecho" 1)
  (command "._undo" "_E")
  (princ)
  )

~'J'~

One Shot

  • Guest
Re: How would you array this horizotally
« Reply #20 on: May 10, 2008, 11:29:04 AM »
~J~

How would I keep the mortar joints between the brick up against eachother instead have them over lap the brick on the right.

Rigjht now when I run the routine with the over hang, there is a small space between the left brick and the mortar joint.  The brick are in the correct position.

The routine work outstanding thou.

Brad

Fatty

  • Guest
Re: How would you array this horizotally
« Reply #21 on: May 10, 2008, 02:05:39 PM »
Yes, you're right :oops:
I'm a bad math, can you rewrite this
part by yourself?

~'J'~


One Shot

  • Guest
Re: How would you array this horizotally
« Reply #22 on: May 10, 2008, 05:10:39 PM »
I can rewrite that part.


Thank you,

Brad

Fatty

  • Guest
Re: How would you array this horizotally
« Reply #23 on: May 10, 2008, 05:35:27 PM »
Hi Brad,
I'll try to do it, but at the moment
I need to doing one of my own projects
This is extremely urgent work for me
 :|
~'J'~


One Shot

  • Guest
Re: How would you array this horizotally
« Reply #24 on: May 10, 2008, 09:28:00 PM »
Fatty,

I will rewrite that part.  I will ask you if I get stuck.

Thank you,

Brad

Fatty

  • Guest
Re: How would you array this horizotally
« Reply #25 on: May 11, 2008, 11:30:10 AM »
Hi Brad,
Try this one instead

Code: [Select]
(defun C:try  (/      brick  cheight    cnt   diff dist height joint  jp1    jp10   jp11   jp12   jp2 jp3
       jp4    jp5    jp6    jp7    jp8   jp9 leng lp     mark   mjoin  mp1    mp2    num   overhang
       p1     p2     ptlist response   rp sjoint step   width  x      y)

  (command "._undo" "_BE")
  (setvar "osmode" 0)
  (setvar "cmdecho" 0)
  (setq width 2.25
height 7.625
cheight 3.625
overhang 3.25
joint 0.375)
  (setvar "orthomode" 1)
  (setq lp (getpoint "\nPick point top left corrner of opening: ")
rp (getpoint lp "\nPick point top right corrner of opening: ")
)
  (initget "Yes No")
  (setq response (getkword
   "\nIs there an overhang beyond the opening or no opening?\n (Yes/No) <Y>: "))
  (if (not response)
    (setq response "Yes"))
  (if (eq "Yes" response)
    (progn
      (setq mark T)
      (setq lp (list (- (car lp) overhang) (cadr lp))
    rp (list (+ (car rp) overhang) (cadr rp))
    )
      )
    (setq mark nil)
    )

  (setq dist (distance (trans lp 0 1) (trans rp 0 1)))
  (setq cnt (fix (/ dist width)))
  (setq leng (* cnt width))
  (setq diff (- dist leng))

  (if (< diff 0)
    (progn
      (setq cnt (1- cnt))
      (setq leng (* cnt width))
      (setq diff (- dist leng))))
  (setq mjoin (/ diff (1- cnt)))

  ;; recalculate till the joint will have a desired size :
  (while (< mjoin 0.25)
    (progn
      (setq cnt (1- cnt))
      (setq leng (* cnt width))
      (setq diff (- dist leng)))
    (setq mjoin (/ diff (1- cnt))))
  (setq leng (+ (* cnt width) (* (1- cnt) mjoin)))

  ;; compare result with length of opening 
  (if (not (equal leng dist 0.001))
    (progn
      (princ "\nWrong result, you're the dumb, Fatty")
      (exit)
      (princ)
      )
    )
  ;; get the step of an array 
  (setq step (+ width mjoin))

  ;; draw a single brick
  (setq p1 (list (car lp) (cadr lp))
p2 (list (+ (car lp) width) (+ (cadr lp) height))
)

  (command "._zoom" "_W" p1 p2)
  (setvar "clayer" "0")
  (setvar "cecolor" "22")
  (command "._rectang" p1 p2)
  (command "extrude" "L" "" cheight)
  ;; array 
  (setq brick (entlast))
  (command "-array" brick "" "R" "" cnt step)

  ;; draw a single joint
  (setq mp1 (list (car p2) (cadr p1))
mp2 (list (+ (car p2) mjoin) (cadr p2))
)
  (setvar "cecolor" "9")
  (command "._rectang" mp1 mp2)
  (command "extrude" "L" "" cheight)
  ;; array   
  (setq sjoint (entlast))
  (command "-array"
   sjoint
   ""
   "_R"
   ""
   (1- cnt)
   step)

  ;; draw mortar joint by style

  (if (not mark) ; without overhangs
    (progn
      (setq jp1 lp
    jp2 (list (car lp) (+ (cadr lp) height))
    jp3 (list (car rp) (cadr jp2))
    jp4 (list (car jp3) (cadr jp1))
    jp5 (list (+ (car jp4) joint) (cadr jp4))
    jp6 (list (car jp5) (+ (cadr jp3) joint))
    jp7 (list (- (car jp1) joint) (cadr jp6))
    jp8 (list (car jp7) (cadr jp1))
    )

      (setq ptlist (list jp1 jp2 jp3 jp4 jp5 jp6 jp7 jp8))
      (entmake
(append
  (list
    '(0 . "LWPOLYLINE")
    '(100 . "AcDbEntity")
    '(8 . "0")
    '(100 . "AcDbPolyline")
    (cons 90 (length ptlist)) ;number of verticies
    (cons 70 1) ;closed
    (cons 62 9) ; color
    (cons 43 0.0) ;constant width
    )
  (mapcar '(lambda (x) (cons 10 x)) ptlist))

)
      (command "extrude" "L" "" cheight)
      )
                                  ;; with overhangs
    (progn
      (setq jp1 lp
    jp2 (list (car lp) (+ (cadr lp) height) (caddr lp))
    jp3 (list (car rp) (cadr jp2) (caddr lp))
    jp4 (list (car jp3) (cadr jp1) (caddr lp))
    jp5 (list (- (car jp4) overhang) (cadr jp4) (caddr lp))
    jp6 (list (car jp5) (- (cadr jp5) joint) (caddr lp))
    jp7 (list (+ (car rp) joint) (cadr jp6) (caddr lp))
    jp8 (list (car jp7) (+ (cadr jp5) joint height) (caddr lp))
    jp9 (list (- (car lp) joint) (cadr jp8) (caddr lp))
    jp10 (list (car jp9) (cadr jp6) (caddr lp))
    jp11 (list (+ (car jp1) overhang) (cadr jp6) (caddr lp))
    jp12 (list (car jp11) (cadr jp5) (caddr lp))
    )

      (setq ptlist (list jp1 jp2 jp3 jp4 jp5 jp6 jp7 jp8 jp9 jp10 jp11 jp11 jp12))
      (entmake
(append
  (list
    '(0 . "LWPOLYLINE")
    '(100 . "AcDbEntity")
    '(8 . "0")
    '(100 . "AcDbPolyline")
    (cons 90 (length ptlist)) ;number of verticies
    (cons 70 1) ;closed
    (cons 62 9) ; color
    (cons 43 0.0) ;constant width
    )
  (mapcar '(lambda (x) (cons 10 x))
  (mapcar '(lambda (y) (list (car y) (cadr y))) ptlist))
  )
)
      (command "extrude" "L" "" cheight)
      )
    )
  (command "._zoom" "_P")
  (setvar "osmode" 0)
  (setvar "cmdecho" 1)
  (command "._undo" "_E")
  (princ)
  )

~'J'~

deegeecees

  • Guest
Re: How would you array this horizotally
« Reply #26 on: May 11, 2008, 12:36:35 PM »
O.T....   7.625 is the diameter of an M16 round if I remember correctly.   :wink:

The M16A1 uses a 5.56 mm NATO round .
The M60, M14, AK47, 7.625mm Nato round.

D'oh! Been a while.

Gotta remember to groogle things before I post.

One Shot

  • Guest
Re: How would you array this horizotally
« Reply #27 on: May 11, 2008, 08:19:50 PM »
O.T....   7.625 is the diameter of an M16 round if I remember correctly.   :wink:

The M16A1 uses a 5.56 mm NATO round .
The M60, M14, AK47, 7.625mm Nato round.

D'oh! Been a while.

Gotta remember to groogle things before I post.
When were you in and what branch?

deegeecees

  • Guest
Re: How would you array this horizotally
« Reply #28 on: May 12, 2008, 10:21:03 AM »
86-89, U.S. Army, 55B Ammo Spec, 60th Ord Co., Friedburg Germany. I went stateside just before the wall came down in Berlin.

One Shot

  • Guest
Re: How would you array this horizotally
« Reply #29 on: May 16, 2008, 04:18:18 PM »
Here is my next step in this lisp routine.  How am I doing so far.

daron

  • Guest
Re: How would you array this horizotally
« Reply #30 on: May 16, 2008, 04:28:58 PM »
For starters:
(defun c:... (/ ... angle ...)) You shouldn't use angle as a variable as it is a predefined function.
Is this pseudocode? (setq width bottom 2.00 (is adjustable up to 2.375) would throw many errors not to mention it lacks parenthesis matching.

You need to have your variables connected as one word as something like (setq width bottom) would set width to bottom which at this point is undefined and would return nil as would (width top) (rightangle brick) etc.

Why are you forcing orthomode? Why are you not getting the current sysvars so you can return the users program back to what they're used to. I would print this code out, fold it into a plane or a ninja star and throw it at you if I had to use it because of the fact that you aren't playing nice with my settings.

BTW, what's with the prognappload? What is that?

Other than that, it looks like you're going in a direction, but I thought you originally had more info than this and what you had before was a good start, it just needed to be cleaned up and expounded upon.

daron

  • Guest
Re: How would you array this horizotally
« Reply #31 on: May 16, 2008, 04:54:30 PM »
Brad, I hope you don't take the previous post as harsh. I intend it only as constructive criticism.

One Shot

  • Guest
Re: How would you array this horizotally
« Reply #32 on: May 16, 2008, 05:37:42 PM »
Brad, I hope you don't take the previous post as harsh. I intend it only as constructive criticism.

Not at all!  I know I have a lot to learn. 

daron

  • Guest
Re: How would you array this horizotally
« Reply #33 on: May 17, 2008, 11:20:57 AM »
Brad, I hope you don't take the previous post as harsh. I intend it only as constructive criticism.

Not at all!  I know I have a lot to learn. 
Me too.

One Shot

  • Guest
Re: How would you array this horizotally
« Reply #34 on: May 20, 2008, 01:59:18 PM »
Brad, I hope you don't take the previous post as harsh. I intend it only as constructive criticism.

Not at all!  I know I have a lot to learn. 
Me too.
Daron, you asked what prognappload was?  It was a typo.  I must have typed it in when I was thinking I was in AutoCAD.   I am trying to figure out how to create the bricks to adjust width to corrisponde to the width of the opening. Along to have the angle to adjust.  See the attachment  4 Course Jackarch Sample.dwg.



Thank you,

brad

daron

  • Guest
Re: How would you array this horizotally
« Reply #35 on: May 20, 2008, 03:00:26 PM »
Daron, you asked what prognappload was?  It was a typo. 

I figured.

I am trying to figure out how to create the bricks to adjust width to corrisponde to the width of the opening. Along to have the angle to adjust.  See the attachment  4 Course Jackarch Sample.dwg.
I think you're starting at the wrong end, but that's just my opinion.
What you need is the width of the opening, the distance from the edge on the lower portion, and the angle both ways on the top and the height for the top. It'll take a little trig to figure it out, but I believe I posted a function that does it when you first asked about it. I could be wrong. As for all the difference in the width of each piece, you need to think about max and min width and then divide the length of the popout to determine how many bricks will be needed. You'd also need to consider the hypotenuse of one brick in order to get an accurate length as long as there are no differences in their angles. Also, you'll need to use your limit of brick size in order to come up with a whole number for the division or that the remainder ends up within your limit. Sounds complicated. I think it is. Take it one step at a time and don't start with the most difficult action to perform. Get the basic points for an outline, then work on building into it.

deegeecees

  • Guest
Re: How would you array this horizotally
« Reply #36 on: May 20, 2008, 03:15:41 PM »
I believe that studying the supplied Adesk tutorial "The Garden Path" would enlighten the O.P. here, no?

One Shot

  • Guest
Re: How would you array this horizotally
« Reply #37 on: May 20, 2008, 03:21:14 PM »
I believe that studying the supplied Adesk tutorial "The Garden Path" would enlighten the O.P. here, no?

Please explain!

deegeecees

  • Guest
Re: How would you array this horizotally
« Reply #38 on: May 20, 2008, 03:29:33 PM »
AutoCad comes with (used to anyway) a tutorial called "The Garden Path" that parallels what you are trying to do. It could give you some greater understanding of the how/what/why in Lisp. They also have it in a VBA tutorial. If you can't locate it locally try punching it in to your favorite search engine.

One Shot

  • Guest
Re: How would you array this horizotally
« Reply #39 on: May 20, 2008, 03:34:15 PM »
AutoCad comes with (used to anyway) a tutorial called "The Garden Path" that parallels what you are trying to do. It could give you some greater understanding of the how/what/why in Lisp. They also have it in a VBA tutorial. If you can't locate it locally try punching it in to your favorite search engine.

Okay,  Thank you very much!

Brad

daron

  • Guest
Re: How would you array this horizotally
« Reply #40 on: May 20, 2008, 04:19:43 PM »
Actually, it is still there and it's improved to work with reactions, which could be the direction this could go.