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

0 Members and 1 Guest are viewing this topic.

SMadsen

  • Guest
Help but please no code.
« Reply #15 on: March 03, 2004, 09:14:49 AM »
Hey Hudster,
Nice little project you've given yourself there. Before you know it, you'll be writing routines to calculate and draw intensity curves in candela (or lux or lumen or .. )

Getting the geometry of a room can be done in various ways depending on your intentions. But I'd start off getting simple corner points as you suggest in your initial post - pretending it's always a square room. Later you can decide what to do with oddly shaped rooms and such.

Have a look at GETPOINT for a starter. Once having identified points, you'll need to do some calculations - getting some angles and subtract x's and y's - to get the geometry. Because points are lists of 3 reals, you'll probably need to look at some list handling stuff, such as CAR, CADR and CADDR.

Pretending rooms are always square, you could use GETDIST to have the user specify length and width, but you'd still need angles and it would be harder to adjust for oddly shaped rooms.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Help but please no code.
« Reply #16 on: March 03, 2004, 09:17:09 AM »
How about expanding on the pseudo code a bit more.

Quote
1. find the length and width of a room.
2. input the desired amount of fittings for length and width.
3. insert an array of a selected block, at spacings decided by
the number of fittings divided by length and width.


You need to get closer to the code by being more specific about what
you want to do. As posted earlier, how would YOU actually draw it?
Then translate that into code.

Here is my version of pseudo code

Briefly display instructions
Get width of room & # of lights
Get depth of room & # of lights
Calculate layout, What is the formula
.   distance / (1+ # of lights) ??
Get the lower left corner of the room
Insert the first light @ (LLcorner + widthOffset + DepthOffset)
Use array command with entlast  widthOffset  DepthOffset
Done


Change this to suite your method.

Then start your codeing
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 #17 on: March 03, 2004, 10:52:48 AM »
Can I use the GETDIST function and use it to input the length?

i.e.

Code: [Select]
(setq L(getdist))

To give you a rundown of how the lights should be place, take your length L and divide it by the number of fittings, this gives you Distance B, then divide B by 2 to give you Distance A.

So you fittings would be spaced using the distances calculated
i.e. A B B B B B A, this ensures your lights are equally spaced across the room.

Does that make sense?
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

SMadsen

  • Guest
Help but please no code.
« Reply #18 on: March 03, 2004, 11:19:54 AM »
Quote from: Hudster
Can I use the GETDIST function and use it to input the length?
Code: [Select]
(setq L(getdist))


Absolutely.

Code: [Select]

(setq len (getdist "\nInput length of room: "))
(setq wid (getdist "\nInput width of room: "))


This will give the user a choice of dragging a distance on screen or typing a distance at the command line.
Once having those, do your spacing arithmetic. E.g.
Code: [Select]

(setq equalSpace (/ len numOfFittings))
(setq wallToFitting (/ equalSpace 2.0))


.. or whatever you need

hudster

  • Gator
  • Posts: 2848
Help but please no code.
« Reply #19 on: March 03, 2004, 03:12:45 PM »
Right I have made the code for inputing the lenght, width and fittings.

Code: [Select]
(defun c:ltg ()
;;;get the room length
(setq len (getdist "\nInput length of room: "))
 ;;;get the room width
(setq wid (getdist "\nInput width of room: "))
;;;get number of fittings across length
(setq fitlen (getint "\nInput No of fittings along LENGTH: "))
;;;Get number of fittings along WIDTH
  (setq fitwid (getint "\nInput No of fittings along WIDTH: "))
  )


now the hard part, working out the mathematics of setting the array points.

So QUESTION.

How do i get lisp to store the value of the co-ordinates of the first point i click on when I am setting the length and widths.

I figure if i have these coordinates, i hopefully will be able to set the intersection of these two points as being the 0,0 point of the room, and can work aout the insertion point of the first block from there.

or would it be easier to add a line in the lisp asking the user to click on the lower left hand corner of the room? :D
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 #20 on: March 03, 2004, 03:50:54 PM »
Take a look at this.

Code: [Select]
(setq pt (getvar "lastpoint"))
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.

daron

  • Guest
Help but please no code.
« Reply #21 on: March 03, 2004, 04:06:48 PM »
Don't know about you, but I personally happen to like using getpoint:
Code: [Select]
(setq len (getpoint "\nInput length of room: ")
  wid (getpoint len "\nInput width of room: "))
  fitlen (getint "\nInput No of fittings along LENGTH: ")
  fitwid (getint "\nInput No of fittings along WIDTH: ")
  )

Of course, it means you'd have to add more code and separate the coordinates returned, but that could be a good thing.

hudster

  • Gator
  • Posts: 2848
Help but please no code.
« Reply #22 on: March 03, 2004, 04:13:33 PM »
I've went with getpoint

Code: [Select]
(setq zerpt (getpoint "\nClick on the lower left corner of room: "))

What did you mean by seperate out the co-ordinates? You kind of lost me there.
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 #23 on: March 03, 2004, 04:14:31 PM »
The problem I see with using the pick points derived from
getdistance or that method is that the room may have offsets
and the pick points may need adjusting before use.
But that's why there are other methods to use.

Another problem not yet discussed is when the room is not
aligned with the x/y axis. many times I have rooms that
are set at 45 degrees.

If your rooms were always aligned with x/y you could pick
two points like when you use the rectangle command and
have all the point information you need.
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.

SMadsen

  • Guest
Help but please no code.
« Reply #24 on: March 03, 2004, 04:21:43 PM »
Excellent code.

Quote from: Hudster
How do i get lisp to store the value of the co-ordinates of the first point i click on when I am setting the length and widths.


You don't with GETDIST. If you're using that function, you'll need to have the user specify lower-left corner of room or something like that.

CAB, the GETxxx functions do not store input points in LASTPOINT.

However, there is a way to emulate GETDIST and get both points and distance. If you look up GETPOINT in the help files, you'll notice that it accepts an optional point as argument - as well as the normal prompt argument. That point is used for dragging a rubber-band just like GETDIST.

Try this out:

Code: [Select]
(defun getdrag ()
  (if (setq pt1 (getpoint "\nInput length of room: "))
    (if (setq pt2 (getpoint pt1 "Specify second point: "))
      (distance pt1 pt2)
    )
  )
)


This will store the start point, anchor to it when storing the end point and calculate the distance between the points. The reason for the two IF's is that the second GETPOINT will fail if pt1 is nil and that DISTANCE will fail if both points didn't get assigned.

Result is that the user won't notice a difference which method is used. BUT, there is a problem. If the user types a number at the command line, it will anchor at LASTPOINT and attempt to retrieve a second point. Not good.
There is no easy way to tell if GETPOINT recieved a number or a point (I think? umm) - in both instances it will return a point. But we can try to setup GETPOINT to recieve an arbitrary input. This means that typing a distance will be returned as a string, so we'll have to convert it to a number. It also means that if the user inputs anything else than a number, it'll have to be discarded. INITGET 128 allows for arbitrary input and DISTOF does the conversion (or returns nil if not):

Code: [Select]
(defun getdrag ()
  (initget 128)
  (if (setq pt1 (getpoint "\nInput length of room: "))
    (progn
      (if (listp pt1)
        (if (setq pt2 (getpoint pt1 "Specify second point: "))
          (setq dist (distance pt1 pt2))
        )
      )
      (if (= (type pt1) 'STR)
        (setq dist (distof pt1))
      )
    )
  )
  dist
)


Of course, the final comment is that you'll have to discard all of the above because what if the user do not click in the rooms corners but merely points out a distance in the screen somewhere??

Back to square one. Either get length/width AND a corner - or specify that the user NEEDS to click in the corners of the room.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Help but please no code.
« Reply #25 on: March 03, 2004, 04:41:11 PM »
?? point or string

Code: [Select]
(initget 128)
(setq pt (getpoint))
(if (= (type pt) 'LIST)
  ;; got a point
  ;; else got a string
)


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

SMadsen

  • Guest
Help but please no code.
« Reply #26 on: March 03, 2004, 05:09:02 PM »
Nope, that would fail if GETPOINT returns nil. But yes, if GETPOINT is wrapped in an IF from the start then that would suffice. Once past the nil return, it would either be a list or a string.

daron

  • Guest
Help but please no code.
« Reply #27 on: March 03, 2004, 05:12:34 PM »
Would grread work, or is it too much?

SMadsen

  • Guest
Help but please no code.
« Reply #28 on: March 03, 2004, 05:19:27 PM »
GRREAD would be like using CADaver's hobby as a pest control.

I would recommend that Hudster either do the length/width/at-least-one-corner method or the explicit get-corners-of-the-room-or-doom method.

There's no guarantee the user will click at the corners if he/she is only asked for distances.

If it explicitly asks for corners then the user knows which points to input - and that it'll probably fail if some other points are clicked.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Help but please no code.
« Reply #29 on: March 03, 2004, 07:12:10 PM »
Here is another to consider.

Code: [Select]
(if (and (setq LLcorner (getpoint "\nPick the lower left corner."))
         (setq WidthPt (getpoint LLcorner "\nPick a point for width."))
         (setq LengthPt (getpoint LLcorner "\nPick a point for length."))
     )
  (progn
    (setq wid (abs (- (abs (car LLcorner)) (abs (car WidthPt))))
    (setq len (abs (- (abs (cadr LLcorner)) (abs (cadr LengthPt))))

    ;; process code here
  )
); endif
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.