TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: MGEE on November 17, 2003, 08:55:37 AM
-
I would like to generate a pline rectangle, extrude it, and attach 4 nodes or pipe nipples to one side at specific points (of course). And each L,W,& H would be pulled from an XL sheet. ??Shoot me or wound me?
If I could get to this point in understanding Lisp, I could automate a tremendous amount of my daily duties.
Thanks for any insight.
MGEE
Edited:
Also I've made a custom Menu with my personal buttons and saved it as custom_MG but I have to load it each time I start up Acad.How do you make it load automatically?
Thanks MGEE
7Edit: I renamed this topic.
-
ummm as far as the second part of your question you may wanna read the recent loading custom menus topic. did you put the directory in autocads search path? if you don't know go to tools/options/files and add the folder where your menu is stored. see i'm learning guys :lol:
dan
-
In The Visual LISP Developers Bible 2003 Edition By David M. Stein there is a chapter (21) on working with Excel, with examples.
As far as the menu goes, perhaps you could upload your .mns file to the lilly pond for us to look at.
http://theswamp.org/lilly.pond/
-
Oh dear .. you need to read from Excel? What weapon would you prefer??
You know, some ppl would cut in here and recommend that you use VBA for these kinds of tasks. I would too, but of course it is possible to do from AutoLISP.
What version of Acad are you running? Should we assume that Excel is open when doing yer thing or should it be opened by AutoCAD? Would you like the fullblown type library solution or an anonymous solution?
-
Ah yes, read Dave's Bible first. Excellent!
-
Am I missing something, guys? I see no reference in the opening thread on using excel for anything.
-
And each L,W,& H would be pulled from an XL sheet. ??
^ ? .. and it did say "external data" (now it does at least)
-
You know? I read that 3 or 4 times and never saw it.
-
You know? I read that 3 or 4 times and never saw it.
It is Monday Daron, I can tell becuase of my CDATE question!
-
Okay! I'll go home now.
-
daron probably looks very similar to ren right about now
dan
-
If I'm communicating externally from Acad with anything I go the VBA way. But like Stig mentioned, it is possible either way. I suppose it all depends upon how much programming knowledge you have and personal preference
Do you have any VBA or (V)Lisp experience ?
-
daron probably looks very similar to ren right about now
dan
minus the pink-eye.
-
Don't have any VBA or VLisp knowledge.
On the other matter, I can & did build a custom menu but I have to load it myself every time I start ACAD.
Sorry I'm running Acad 2002
-
Is there any reason you are drawing a rectangle using a pline then extruding it as opposed to creating a 3d solid (box) ?
-
Nope. I guess I need to put my thinking cap on & get this thing fine tuned to the quickest, easiest method to get my end result.
Do you know of a way to link several commands together? Maybe that could be a step in another dirction but better than manually drawing the whole thing?
Thanks
-
Do you know of a way to link several commands together?
I think that would be called putting user-defined functions into a main function.
-
Making the rectangular box (is this a tank or reservoir) is
easy. Extracting the data from excel is the hard part. Have
you search for 3D routines that does similar things that you
want either at Cadalog.com or Caddepot.com. I think iHave
seen some demo that creates ANSI flanges.
-
I guess I need to put my thinking cap on & get this thing fine tuned to the quickest, easiest method to get my end result.
you mentioned that the data for the nipples (down Dent) was in an XLS spreadsheet. If you had the "box" data in there as well, you could draw the whole thing in one go.
How is your data formatted ? I mean, exactly what data do you store in respect to the nipples ? ~ diameters, lengths ~ how are they positioned ? relative to the box ?
-
In a cell would be say from insertion point, (25"X,112"Y)
There would be a diameter and length. (4.5"diax6"l) for the size of the nipple. And the box is actually representing an Evaporative Condenser. I would have 2 or 3 Fans on one side say the 0 direction and the connections nipples on the 270 direction. If I can get code to place the nipples, then I think I can expand on it to cut the holes for the fans. And then add an insert of a block that is linked to the XLS which would be the Fan & Grill.
How can I post a pic of one?
-
How can I post a pic of one?
see over here (http://theswamp.org/phpBB2/viewtopic.php?t=150&highlight=lily+pond)
-
... the data for the nipples (down Dent) ...
Funny coincidence, there's also a guy on this forum called Dent :lol:
-
O.K. I posted a pic in the Lilly pond.
-
And the next thing you should do, since we really don't want to make everybody hunt it down is to copy the link and post it, like this [url]http://theswamp.org/lilly.pond/MGEE/EVAP.JPG[/url] or use [img][/img]
-
Appologies to all, as you can tell I'm new to posting img's.[/url]
-
ah, glad to see someone esle is watching this topic as well.
Q: do you have access to Access ? (if you see what I mean !)
the reason I ask is because I've never used Vlisp to connect to a spreadsheet but I have connected through VBA to an MDB file.
Now, if it were me :shock: I'd do it the following way:
Have all the info (Box length, width depth etc + all cylinderinfo) stored in Access and just run a query to pull the data from Access and create the whole shebang in one go. Or you could do it all via a dialogue box...
you mentioned that you have the info in a spreadsheet...In a cell would be say from insertion point, (25"X,112"Y)
what insertion point ? is that relative to the origin of the box ? or an absolute coordinate ?
Is the nipple a cylinder a tube or a revolved solid ? Are there always the same number of fans / nipples / whatever ?
what we really need form you is some pseudo code detailing exactly the steps you need to take to complete one of these thingamajiggies
i.e.
prompt user for box dimensions
create box
prompt for face to add nipples to
add nipples
prompt for face to add fans to
add fans
etc etc
also, what version of Acad, Excel, Acces do you have ? it all makes a difference
-
Appologies to all, as you can tell I'm new to posting img's.[/url]
It's okay. Everybody needs to be taught eventually.
-
hendie or Daron,
I once heard of a program that recorded your every move. As your talkin about giving you. What's your thoughts on this? Saposidly, it wrote a lisp routine of your footprints? I can actually give you a rundown buy drawing one and then cut & paste the text window. would that be good enough?
Also, I'd like to have the ONE user input option to select the Model of this thingamajiggie cause there are several, and it's insertion point. Which would be the refference for the rest of the entities to be generated by the VBA routine.
-
ooohh time is tihgt and I'm just about to finish here and I'm on holiday tomorrow...
I think you might be missing the point slightly here.
What you have to consider is how many variables there are.. by that I mean, is the box always the same size ? are there always the same number of nipples ? are they always the same diameter, same number of fans etc.... ad infinitum...
If you want to write code to take care of this function for you , you have to consider taking all the variables into account. It's no good designing a programme to create a box with three nipples when you want to draw a box with 2 or 4 ! see wot I mean ?
One major problem here is that you know what you need to draw ~we don't know unless you tell us.
The best person to answer this question is you.... consider what you want to achieve.... now how do you want to achieve that target... think carefully !
my interpretation of what you have told us so far is something along the lines of...
create a box
add (up to 3 {or more}) nipple extrusions
add (some number of) fans
Now, I would probably go with a dialogue box asking for box length width & height
with a section for nipples ~ number of, diameters and lengths
same for fans
now you need to know where to place the nipples etc, so at some point you need to change the UCS, so you probably want the "insertion" point for the nipples relative to some origin on the box
same for the fans
and any other gizmos to be attached
SO, I would
1 create the box,
prompt the user for a "face" for the nipples to be inserted on
change the UCS to that "face"
insert the nipples
repeat the process for the fans etc
and any other gizmos
or take it a step further, have ALL the info in a database and just query the database to create the whole shebang. But you would need to have the info stored in the database in a format that is suitable for the programme.
-
O.K. I'm looking at the tutorials for VBAIDE right now. So with the Grace of god I'll develope this application that looks at the XLS sheet to get all the info from, with the exception of the insertion point. Thank you for all your knowledge & TIME.
I'm sure we will be talking more in the future.
Have a GREAT Holiday and God Bless.
MGEE
-
ok, here's something to get you started....
(http://theswamp.org/swamp.files/hendie/Form1.jpeg)
create userform with 5 textboxes and 1 command button as shown above, double-click the command button and add this code....
Private Sub CommandButton1_Click()
Dim length As Double, width As Double, height As Double
Dim boxObj As Acad3DSolid
Dim center As Variant
Dim BoxPnt As Variant
Dim cylinderObj As Acad3DSolid
Dim radius As Double
Dim Cylcen As Variant
Dim Cylheight As Double
' get data for the box, first get the insertion point from user
Me.Hide
BoxPnt = ThisDrawing.Utility.GetPoint(, "Enter a point for centre of box: ")
length = TextBox1.Value
width = TextBox2.Value
height = TextBox3.Value
' now create the box
Set boxObj = ThisDrawing.ModelSpace.AddBox(BoxPnt, length, width, height)
' before we can add the cylinder, we need to define a new UCS and set it current
' So, let's get the current UCS so we can restore it later
Dim UCSColl As AcadUCSs
Set UCSColl = ThisDrawing.UserCoordinateSystems
Dim ucsObj As AcadUCS
Dim CurrUCS As AcadUCS
Set CurrUCS = ThisDrawing.ActiveUCS
' Now change the viewing direction so it's easier to place the cylinder
Dim NewDirection(0 To 2) As Double
NewDirection(0) = -1: NewDirection(1) = -1: NewDirection(2) = 1
ThisDrawing.ActiveViewport.Direction = NewDirection
ThisDrawing.ActiveViewport = ThisDrawing.ActiveViewport
ZoomAll ' so we can see the box we just created
' Now we can create the new UCS by picking 3 points on a box face
Dim origin As Variant
Dim xAxisPnt As Variant
Dim yAxisPnt As Variant
origin = ThisDrawing.Utility.GetPoint(, "Enter ORIGIN point for face: ")
xAxisPnt = ThisDrawing.Utility.GetPoint(, "Enter point on X Axis : ")
yAxisPnt = ThisDrawing.Utility.GetPoint(, "Enter point on Y Axis : ")
Set ucsObj = UCSColl.Add(origin, xAxisPnt, yAxisPnt, "Face1")
ThisDrawing.ActiveUCS = ucsObj
' now get the cylinder values from the form
radius = TextBox4.Value
Cylheight = TextBox5.Value
' now get the insertion point of the cylinder
Cylcen = ThisDrawing.Utility.GetPoint(, "Enter a point for centre of cylinder: ")
' and since we've got the point in the World UCS we need to convert it to our new UCS
Cylcen = ThisDrawing.Utility.TranslateCoordinates(Cylcen, acWorld, acUCS, False)
Dim Cyl(0 To 2) As Double
Cyl(0) = Cylcen(0)
Cyl(1) = Cylcen(1)
' but since the solid is created using the picked point as the object CENTRE, we
' need to change the "Z" value so that the object is created on the face of the box
Cyl(2) = 0 + (Cylheight / 2)
' and create the cylinder
Set cylinderObj = ThisDrawing.ModelSpace.AddCylinder(Cyl, radius, Cylheight)
' then transform it to our new UCS
Dim TransMatrix As Variant
TransMatrix = ucsObj.GetUCSMatrix()
cylinderObj.TransformBy (TransMatrix)
cylinderObj.Update
ZoomAll
Unload Me
End Sub
I've given this as an example. It will prompt you for an insertion point for the "box", then ask for 3 points for a new UCS, then create the cylinder on the new UCS.
At least it should get you started.