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

0 Members and 1 Guest are viewing this topic.

hudster

  • Gator
  • Posts: 2848
Help but please no code.
« Reply #45 on: April 12, 2004, 05:32:23 AM »
when I try to run it does everything up to the array command then i get the following error message.

Code: [Select]
Command: ARRAY
Select objects: <Bad Entity name: 7EF70F78>
RECTANGULAR 3 2 5000.000000000000 2500.000000000000 UNDO End
Select objects: *Cancel*


so what am I doing wrong?
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 #46 on: April 12, 2004, 08:11:27 AM »
Try this version.

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 (entlast))
         ;(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.

hudster

  • Gator
  • Posts: 2848
Help but please no code.
« Reply #47 on: April 12, 2004, 09:27:42 AM »
that works.

Excellent work.
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

hudster

  • Gator
  • Posts: 2848
Help but please no code.
« Reply #48 on: April 29, 2004, 05:57:29 AM »
Stage Two.

I want to include an option for lights being in a ceiling grid.

So I need to do the following.

1. Determine whether a ceiling grid is present.
2. Determine the size of the ceiling tiles.
3. work out the insertion point of the lights dependant on the insertion point of the grid, i.e. full tile or intersection at room center.
4. Insert the lights using the information gained from above.

any hints or ideas?
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue