TheSwamp

Code Red => .NET => Topic started by: MickD on December 08, 2005, 12:35:27 AM

Title: Beta testers - 3d section creator
Post by: MickD on December 08, 2005, 12:35:27 AM
For those with A2006 and some spare time who like to play in 3d, I have attached a .net dll for beta testing.

It creates a 3d solid of a section profile drawn as a polyline. There's more info at the site but the thing I'm trying to acheive is to get the length from a 3d solid extrusion and I think I have a suitable solution.

You can draw any shaped polyline from scratch or insert a block of your standard sections into wcs and away you go. It doesn't matter which ucs you're in when creating the solid as long as you have your poly in the wcs everything will (should :-o ) be fine

Let me know what you think, especially if you have problems.

Cheers,
MickD.

update - version 0.2 - all creation and transformation functions carried out by the DCS_Solid class to create itself regardless of ucs enabling use of the class without using the 'test' command.
Title: Re: Beta testers - 3d section creator
Post by: MickD on December 08, 2005, 12:57:29 AM
There's some more info here http://www.dcservices.net.au/3dHome.htm

Cheers.
Title: Re: Beta testers - 3d section creator
Post by: Kerry on December 08, 2005, 12:58:26 AM
Ohhh shiney, new ...

something to play with tomorrow :-)
Title: Re: Beta testers - 3d section creator
Post by: MickD on December 08, 2005, 01:00:48 AM
heh, don't worry, it's pretty knocked together and may break easily (like some shiny objects), shouldn't take too long to test :D
Title: Re: Beta testers - 3d section creator
Post by: Kerry on December 08, 2005, 01:27:25 AM
Hi Mick,
Loads and runs fine.
Draws and querys correctly.

Just tried a simple run !!

Will put into destruct mode tomorrow.

The Prompts may need a bit of work < for the uninitiated>


hehehe
"Whoops! that shouldn't have happened!.."
Title: Re: Beta testers - 3d section creator
Post by: MickD on December 08, 2005, 01:42:49 AM
Whoops! I forgot to fix those debugging comments  :roll:  :laugh:
Title: Re: Beta testers - 3d section creator
Post by: David Hall on December 08, 2005, 08:24:54 AM
Those are the best kind.  You have got to have humor when programming
Title: Re: Beta testers - 3d section creator
Post by: Kerry on December 08, 2005, 07:01:28 PM
Mick, must the solids be drawn with the "Test" routine.

That doesn't seem right, so I assume Ive drawn them in a different manner than you require.

I'd assumed < nasty word, that> that your solObj Class would be constructed/initialised with a conventional ACAD solid, and do its mojo from there.

Everything Seems fine otherwise.

 
Title: Re: Beta testers - 3d section creator
Post by: Kerry on December 08, 2005, 07:02:33 PM
Geeze, does that ^ ^ make sense to you ?
Title: Re: Beta testers - 3d section creator
Post by: MickD on December 08, 2005, 07:22:58 PM
Yes that makes sense (if I understand it the way you're sayin it of course :D).

If you have a look in the object browser, the only class I'm really using is the DCS_Solid class and you will notice that you must pass a ref to a 3d solid in the constructor. This is both at creation and when you want to view properties of the object. Just pass it in, don't do anything with it as my class will look after that.

The matrix mojo is outside of the class [at the moment] so yes you will have trouble creating the objects where you want without using 'test', working on that now and also so you can put your name of the object at creation time. This is more to test on someone elses' machines more than anything to see what happens with different enviroment settings etc. but there should'nt be any problems. I'll start tidying it up now to something more usable.
The main goal will be to have a drawing full of 3d objects, loop through them, create a DCS_Solid with them to extract the properties for export, parts lists or whatever (that's the good bit!).

Thanks for the feedback :)
Title: Re: Beta testers - 3d section creator
Post by: Kerry on December 08, 2005, 07:28:20 PM
Cool !
Title: Re: Beta testers - 3d section creator
Post by: MickD on December 14, 2005, 04:18:40 PM
Update (download from original post)
version 0.2 is now more usable from a developers point of view, you can use it how you wish, just feed it what it needs and away you go. It will place the section anywhere you pick regardless of ucs.

Next - properties dialog so you can view and edit the stored info of the solid for part numbers and member names etc.
Title: Re: Beta testers - 3d section creator
Post by: Kerry on December 14, 2005, 06:17:22 PM
Looks like you've been busy Mick.

I'll have a play later ..
Title: Re: Beta testers - 3d section creator
Post by: MickD on December 14, 2005, 06:43:09 PM
Looks like you've been busy Mick.

Yep, I'm putting it to work in the new year (with other mods to suit my office of course ;) ). After the properties dialog I'll be doing a data exporter for BOM's and parts lists, just to a comma delimitted text file for now, that way you can import it into excel or access easily for reporting etc.

Here's some sample code for using the dll if ref'ing into your own project to give you an idea of creating and using the properties of the solid object.
Code: [Select]
//Test commands to use the DCS_3D class library
//By Mick Duprez 15th Dec. 2005
//
//TEST - uses the DCS_Solid class to create a 3d solid entity which also
//stores some data for mark no.s and use with BOM's etc.
//
//GETLEN - an example of using the properties of a 3d solid created
//using the DCS_Solid class.
using System;
using System.Collections;

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.EditorInput;


namespace DCS_3D
{

public class Commands
{

[CommandMethod("TEST")]
public static void TestCommand_1()
{
//Set up some tools we will need here
Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
Database db = HostApplicationServices.WorkingDatabase;
Transaction tr = db.TransactionManager.StartTransaction();
BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead, false);
BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
//get some user input
PromptEntityResult pickedEnt = ed.GetEntity("\nPick a closed Polyline to extrude:");
PromptPointResult insPt = ed.GetPoint("\n Pick insertion point on the polyline:");
PromptPointResult pnt1 = ed.GetPoint("Pick start point...");
PromptPointOptions ppo = new PromptPointOptions("Pick the end point\n");
ppo.UseBasePoint = true;
ppo.BasePoint = pnt1.Value;
PromptPointResult pnt2 = ed.GetPoint(ppo);
PromptResult stringres = ed.GetString("\nEnter Name for the new object:");

try
{
//create a new solid object passing in the user info
Entity ent = (Entity)tr.GetObject(pickedEnt.ObjectId, OpenMode.ForWrite);
Solid3d sol = new Solid3d();
DCS_Solid dcsSolid = new DCS_Solid(ref sol);
dcsSolid.Extrude(stringres.StringResult,ent,insPt.Value,pnt1.Value,pnt2.Value);

btr.AppendEntity(sol);
tr.AddNewlyCreatedDBObject(sol,true);
tr.Commit();
}

catch
{

}
finally
{
tr.Dispose();
}

}

[CommandMethod("GETLEN")]
public void RotateToWorld()
{
Database db = HostApplicationServices.WorkingDatabase;
Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
Transaction tr = db.TransactionManager.StartTransaction();
try
{

PromptEntityResult res = ed.GetEntity("\nPick a 3d Solid to get the info:");
Solid3d solid = (Solid3d)tr.GetObject(res.ObjectId, OpenMode.ForWrite);
if(solid != null)
{
DCS_Solid sol = new DCS_Solid(ref solid);
ed.WriteMessage("\nLength of the picked " + "\"" + sol.SectionName + "\"" + " = " + sol.Length.ToString());
}
tr.Commit();
}
catch
{
ed.WriteMessage("Object does not contain any data!..");
}
finally
{
tr.Dispose();
}
}

}
}

Title: Re: Beta testers - 3d section creator
Post by: Draftek on December 15, 2005, 07:47:42 AM
wow, thanks Mick. I'll be trying this out as soon as I put out the forest fires..