Author Topic: Help but please no code.  (Read 18456 times)

0 Members and 1 Guest are viewing this topic.

daron

  • Guest
Help but please no code.
« Reply #30 on: March 04, 2004, 07:57:45 AM »
What CAB's done with the value of wid and len is what I meant by separating out the values.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Help but please no code.
« Reply #31 on: March 04, 2004, 09:52:17 AM »
Here is a visual example.

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.

DEVITG

  • Bull Frog
  • Posts: 479
Going far beyond
« Reply #32 on: March 05, 2004, 06:35:36 PM »
Could be "MINSERT"  a good way to draw the blocks on?

As defined length fractions distance as

Quote

ABBBBBA



The width could be
Quote


CDDDDDC



So the insert point should be the A and C distance  from origin

The row number =  by the previous user imput
The column number = by the same way

The row space A

The column space D

Even the angle could match the angle of the room .
Location @ Córdoba Argentina Using ACAD 2019  at Window 10

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Help but please no code.
« Reply #33 on: March 05, 2004, 08:30:21 PM »
I don't know if minsert would be a good option since it inserts in a complete grid...
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

hudster

  • Gator
  • Posts: 2848
Help but please no code.
« Reply #34 on: March 31, 2004, 06:46:11 AM »
I've been working on this in my very limited free time and I've come up with this

Code: [Select]
;;;
;;;Lighting array lisp routine
;;;Created by Andy Hudson
;;;March 2004
;;;
(defun c:ltg (/ X1 Y1 FX FY P1 PX PY block PXA PYA) ;set as local variables
  (setq X1 (getdist "\nInput length of room along X Axis: ")) ;get length
 (setq Y1 (getdist "\nInput width of room along Y Axis: ")) ;Get width
  (setq FX (getint "\nInput No of fittings along X Axis: "))
  (setq FY (getint "\nInput No of Fittings along Y Axis: "))
  (setq P1 (getpoint "\nSelect the lower left hand corner: ")) (terpri) ;set the 0,0 point
  (command "UCS" "O" P1)
  (setq P1 (LIST 0 0))
  ;;;
  (setq PX (/ X1 FX)) ;;length divide by fittings
  (setq PXA (/ (/ X1 FX) 2.0)) ;;divided by 2
   (setq PY (/ Y1 FY)) ;;width divided by fittings
  (setq PYA (/ (/ Y1 FY) 2.0)) ;;divided by 2
  ;;;
  (setq block (getstring "Enter block name you wish to insert: ")) ;;get block
;;;
  (command "-insert" block (list PYA PXA) "1" "" "0") ;;insert block
;;;
  (COMMAND "-ARRAY" "LAST" "" "RECTANGULAR" FY FX PY PX)
  (COMMAND "UCS" "P")
  (COMMAND "UCS" "P")
 (princ) ;;clean exit
  )


it's almost there but it doesn't quite work right and I can't figure out why.

this is an image of how I want it to lay out the fittings but it's always off a wee bit.



Any Ideas?
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

SMadsen

  • Guest
Help but please no code.
« Reply #35 on: March 31, 2004, 08:43:39 AM »
Andy, I haven't tried your routine but could running osnaps cause the UCS to snap to another point than P1? Just a thought.

hudster

  • Gator
  • Posts: 2848
Help but please no code.
« Reply #36 on: March 31, 2004, 09:09:11 AM »
I've tried it with snaps off, but it's still out.

not by much only 50mm, but enough to annoy me. :cry:
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

hudster

  • Gator
  • Posts: 2848
Help but please no code.
« Reply #37 on: March 31, 2004, 09:29:48 AM »
it was the snaps, I changed the osmode to 103 and it worked.

But it threw up another problem.  the routing only works in square grids, i.e 2X2 , 3X3, 4X4 etc.

if you try 2X4 it doesn't work.

Someone in my work suggested it may be to do with integers and real numbers.  but I don't know, I'm new to lisp and every function is a discovery to me.
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

SMadsen

  • Guest
Help but please no code.
« Reply #38 on: March 31, 2004, 10:30:48 AM »
Nope, GETDIST returns reals so that part is fine. Just noticed that you've switched x and y in the INSERT command though:

(command "-insert" block (list PYA PXA) "1" "" "0")

should be

(command "-insert" block (list PXA PYA) "1" "" "0")

SMadsen

  • Guest
Help but please no code.
« Reply #39 on: March 31, 2004, 10:48:08 AM »
Try this minor alteration. Instead of messing with UCS, it merely offsets the point with the lower left point in P1.
Also, undo is added and osnaps are turned off temporarily.

Code: [Select]
(defun c:ltg (/ X1 Y1 FX FY P1 PX PY block PXA PYA osm)
  ;set as local variables
  (setq X1 (getdist "\nInput length of room along X Axis: ")) ;get length
  (setq Y1 (getdist "\nInput width of room along Y Axis: "))  ;Get width
  (setq FX (getint "\nInput No of fittings along X Axis: "))
  (setq FY (getint "\nInput No of Fittings along Y Axis: "))
  (setq P1 (getpoint "\nSelect the lower left hand corner: "))
;;;
  (setq PX (/ X1 FX))
  ;;length divide by fittings
  (setq PXA (+ (car P1) (/ PX 2.0)))
  ;;divided by 2
  ;; - plus X coord of P1
  (setq PY (/ Y1 FY))
  ;;width divided by fittings
  (setq PYA (+ (cadr P1) (/ PY 2.0)))
  ;;divided by 2
  ;; - plus Y coord of P1
;;;
  (setq block (getstring "Enter block name you wish to insert: ")) ;get block
;;;
  ;; - If block exists then go ahead
  (cond ((tblsearch "BLOCK" block)
         ;; - Done with user input -> set OSMODE to zero
         (setq osm (getvar "OSMODE"))
         (setvar "OSMODE" 0)
         ;; - Let user be able to undo
         (command "UNDO" "Begin")
         (command "-insert" block (list PXA PYA) "1" "" "0")
         ;;insert block
;;;
         (COMMAND "-ARRAY" "LAST" "" "RECTANGULAR" FY FX PY PX)
         (command "UNDO" "End")
         (setvar "OSMODE" osm)
        )
  )
  (princ)
  ;;clean exit
)

hudster

  • Gator
  • Posts: 2848
Help but please no code.
« Reply #40 on: March 31, 2004, 01:53:13 PM »
That works a lot better than my version.

CAR and CADR are both new functions to me,  like I said, it's all new to me.

Now for stage two, working out how to insert arrays into rooms at a slant.
I'm looking at both the getangle and getorient functions to do this, am I on the right track?
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

SMadsen

  • Guest
Help but please no code.
« Reply #41 on: March 31, 2004, 02:44:36 PM »
Yes, that would be the right track if it should ask for an angle. But it could still be asking for a distance (either with GETDIST as it is now, or with GETPOINT's) and then use ANGLE to calculate the angle.

hudster

  • Gator
  • Posts: 2848
Help but please no code.
« Reply #42 on: April 11, 2004, 02:56:46 PM »
there is a problem with this lisp, it does work, until you try to put a row of fittings when there is only 1 row on the Y axis.  then it seems to fall down.

no matter how hard I look i can't see where it goes wrong.

Any ideas?

 :?
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Help but please no code.
« Reply #43 on: April 11, 2004, 04:51:15 PM »
This was without the angle.

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

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Help but please no code.
« Reply #44 on: April 11, 2004, 06:30:41 PM »
Here is some help with the angle. :)

Code: [Select]
(defun c:ltg (/ x1 y1 fx fy p1 px py block pxa pya osm newbies elast e ang eblk)
  (setq x1 (getdist "\nInput width of room along X Axis: "))
  (setq y1 (getdist "\nInput length of room along Y Axis: "))
  (setq fx (getint "\nInput No of fittings along X Axis: "))
  (setq fy (getint "\nInput No of Fittings along Y Axis: "))
  (setq p1 (getpoint "\nSelect the lower left hand corner: "))
  (setq ang (getangle p1 "\nSelect angle of room width (x-axis): <0>"))
  (if (null ang)
    (setq ang 0)
    (setq ang (* 180.0 (/ ang pi))) ; Radians to Degrees
  )

  (if (or (null fx) (< fx 2))
    (setq fx  1
          px  (/ x1 2)
          pxa (+ (car p1) px)
    )
    (setq px  (/ x1 fx) ;width divided by fittings
          pxa (+ (car p1) (/ px 2.0)) ;divided by 2 plus X coord of P1
    )
  )
  (if (or (null fy) (< fy 2))
    (setq fy  1
          py  (/ y1 2)
          pya (+ (cadr p1) py)
    )
    (setq py  (/ y1 fy) ;length divide by fittings
          pya (+ (cadr p1) (/ py 2.0)) ;divided by 2 plus Y coord of P1
    )
  )


  ;; get block name , default name if enter only
  (setq block
         (getstring "\nEnter block name you wish to insert: <RC-Light> ")
  )
  (if (or (= block "") (null block)) ; use default name
    (setq block "RC-Light")
  )

  ;; - If block exists then go ahead
  (cond ((tblsearch "BLOCK" block)
         (setq osm (getvar "OSMODE"))
         (command "UNDO" "Begin")
         (setvar "OSMODE" 0)
         (setq elast (@cv_entlast))
         (setq newbies (ssadd)) ;empty selection set
         (command "-insert" block (list pxa pya) "1" "" 0)
         (setq eblk (@cv_entlast))
         (ssadd  eblk newbies)
         (command "ARRAY" eblk "" "RECTANGULAR" fy fx)
         (if (> fy 1)
           (command py)
         )
         (if (> fx 1)
           (command px)
         )
         (if (/= ang 0)
           (progn
             (setq e (if elast
                       (entnext elast)
                       (entnext)
                     )
             )
             (while e
               (ssadd e newbies)
               (setq e (entnext e))
             )

             (command ".rotate" newbies "" p1 ang)
           )
         )
         (command "UNDO" "End")
         (setvar "OSMODE" osm)
        )
        ;;  ELSE =====================================
        ((prompt (strcat "\n" block " Block not found."))
        )
  )
  (princ) ; clean exit
)


;;------------------------------------------------------------
;; Function to get the absolutely last entity in the database:
;;
(defun @cv_entlast (/ e elast)
  (setq elast (entlast))
  (while (setq e (entnext elast))
    (setq elast e)
  )
  elast
)
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.