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

0 Members and 1 Guest are viewing this topic.

hudster

  • Gator
  • Posts: 2848
Help but please no code.
« on: March 02, 2004, 11:17:25 AM »
I'm trying to write a lisp routing to set out lighting within a room.

What I want to do is click on 4 corners of a room to allow AutoCAD to calculate the room area, then after I input the number of fittings required in the x and y directions, lisp calculates the spacing required and insert a block at the required spacings

Now as I'm a newbie at this and don't have a clue where to start, I'm hoping someone will take me under their wing and help me out.

What i don't want is someone to write the lisp for me, that way I'll never learn.

So where do i start?
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Help but please no code.
« Reply #1 on: March 02, 2004, 11:56:12 AM »
Well, I would usually tell someone to start by putting together Pseudo code... You have started that already, whether you know it or not....
So, what you need to do is first identify the order in which you are going to proceed, such as selecting points, etc.. Take into account if the room is square, round etc...
Select a starting point, and continue from there.
Inserting the blocks should be no problem, the rotation and points can be gathered from the object they will be near. When you have a little better idea of pseudo code, get back with us.
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

MDT

  • Guest
Help but please no code.
« Reply #2 on: March 02, 2004, 12:00:56 PM »
Since you want to be self-taught, here's what you
  should be doing:

  1. Open up AutoCAD and read the help files on
      AutoCAD Customization section particularly on
      Autolisp functions. Learn how each function works,
      and where to look for these functions.
  2. To be able to write a lisp routine, you have to know
      what the routine will do and you the author should
      be able to determine the required steps to do the
      task.
  3. For example, in the problem you have posted:
      If you're asked to make the drawing without using
      a lisp routine, how will  you do it?

  After these 3 steps, start writing your routine. Do it as
  you would draw it.....

daron

  • Guest
Help but please no code.
« Reply #3 on: March 02, 2004, 01:27:26 PM »
Look into the divide/measure commands. I wrote something similar to what you describe by using those commands. Hint: both commands can insert blocks and rotate them along the selected object.

hudster

  • Gator
  • Posts: 2848
Help but please no code.
« Reply #4 on: March 02, 2004, 03:01:00 PM »
I thought about the divide/measure command, but the blocks i need to insert have attributes, and as far as i'm aware these commands can't do that.
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Help but please no code.
« Reply #5 on: March 02, 2004, 03:46:04 PM »
I had a thought about how to gather the extreme points of a polygon in a closed area simply by selecting a point within the area. It would work only when the area was a completely closed polygon, but it would be a neat trick.

Here is my thought....
Using the hatch command, create a hatch transparently to the user, make the scale sufficiently large so that it does not show on the screen. Grab that hatch and put it into a variable and extract the boundary from it. Store the boundary points in a list, then erase the hatch.

You should have a points diagram of the boundary of the room to begin aligning objects to.

If you use divide or measure, you could
first grab the last object using entlast then
conceivably insert your blocks aligned (don't worry about the attributes as of yet) then using the last entity from before, grab all entities using entnext from entlast.
Finally starting with the first block you inserted with the command, have the program add the attributes as needed to each individual block.

Heck the more I think about it the more I like it...

I know there is code around too that you could scalp and use for adding the attributes to a block, grabbing all entities from a specific point in the drawing database isn't really a difficult proposition either. Divide and Measure do the insertion hard work for you, and all you need to do is make sure the room is a closed area.

Damn what a good idea, I am just sorry I had not thought of it before you did....

Incedently it would work great for me with the placement of required electrical outlets, much faster....
I can see a pretty good use for this program.
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

daron

  • Guest
Help but please no code.
« Reply #6 on: March 02, 2004, 04:12:02 PM »
The problem I find with hatch and/or boundary (essentially the same thing), is that if there is the slightest degree of objects not being connected, or if there are any arcs, connected or otherwise, then the hatch/boundary will fail. The function I wrote requires you to draw a polyline from point a to point b. This way you know way are always getting a polyline and the right one.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Help but please no code.
« Reply #7 on: March 02, 2004, 04:47:44 PM »
:P .....
Why oh why must you rain on my parade.....
I know that the objects must connect, I even know about problems with splines, but arcs haven't ever given me a problem. go figure....

Anyway, the way I see it, if you know that the lines MUST meet then you will be more diligent to see that they do. Incedently, if I have a drawing that the lines do not meet where they "appear" to meet, I will trash it and redraw it. Of course I always make my lines meet and I always have lines that meet....
I frequently find it easier and faster to completely redraw a plan than to attempt to fix inconsistencies.

So, draw it correctly from the beginning, and then you can use the program to it's fullest potential....

Sorry... got off on a tangent here....

It is still a good idea... we just need to figure out a workaround...
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

daron

  • Guest
Help but please no code.
« Reply #8 on: March 02, 2004, 05:14:42 PM »
I always use snaps to connect lines/arcs/etc. too, but often, we'll get plat drawings from engineers, who also, probably use snaps, but for some reason, this connection between lines and arcs gets lost in translation. Who knows why. I also wrote this routine so it lays down a pline on a specific layer, then divides the blocks onto the pline, then deletes it. Reason: I don't want an electrical outlet to be passed across a door object.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Help but please no code.
« Reply #9 on: March 02, 2004, 05:21:20 PM »
So.... you already have a proggie in place? .. please share the wealth man....I do electrical drawing every day...well, at least 3 or 4 a week ...
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

daron

  • Guest
Help but please no code.
« Reply #10 on: March 02, 2004, 05:27:52 PM »
It's kinda buggy. I wrote it a couple of years ago. I'll share it when hudster gives the okay. I'll send it to you if you like. Maybe you can improve on it.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Help but please no code.
« Reply #11 on: March 02, 2004, 05:34:51 PM »
Please send away... I don't mind putting in a pline to make my life a bit easier...
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 #12 on: March 03, 2004, 03:50:19 AM »
Post your code, i'm ok with that, from what you say your code doesn't do what i'm after anyway.

Basically what i need to do is.

1. find the lenght and width of a room.
2. input the desired amount of fittings for lenght and width.
3. insert an array of a selected block, at spacings decided by the number of fittings divided by lenght and width.
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

daron

  • Guest
Help but please no code.
« Reply #13 on: March 03, 2004, 07:55:24 AM »
Let's see what you've got?

hudster

  • Gator
  • Posts: 2848
Help but please no code.
« Reply #14 on: March 03, 2004, 08:47:28 AM »
and this is where my experience ends.

So, how do I go about specifing user inputs using lisp?
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue