Hi
Is there a way to get the type of the Solid3d object and its parameters?
E.g. Type = Box, Height = 100, Width = 200, Length = 100 (Or something like that)
The following code will find solids in your drawing and dump all its properties. The pros are that you can use this method to learn about any autocad object, the cons that you will have to come up with a more robust way to dump them other than ed.WriteMessage because the Editor buffer is simply not large enough to print out all the properties of a complex autocad object. I usually use NLog for this purpose.
Imports MgdAcApplication = Autodesk.AutoCAD.ApplicationServices.Application <CommandMethod("myMacros", "dumpSolids", Nothing, CommandFlags.Modal)> _ Public Sub dumpSolids_Method() Try Dim activeDoc As Document = MgdAcApplication.DocumentManager.MdiActiveDocument Dim ed As Editor = activeDoc.Editor Dim db As Database = HostApplicationServices.WorkingDatabase Using tr As Transaction = db.TransactionManager.StartTransaction() For i As Long = db.BlockTableId.Handle.Value To db.Handseed.Value - 1 Dim id As ObjectId = ObjectId.Null Dim h As New Handle(i) If db.TryGetObjectId(h, id) Then If id.ObjectClass.Name = "AcDb3dSolid" Then Dim ent As Entity = CType(tr.GetObject(id, OpenMode.ForRead, True), Entity) For Each p As System.Reflection.PropertyInfo In ent.GetType().GetProperties() Try Dim displStr As String = String.Format(" {0}: '{1}'", p.Name, p.GetValue(ent, Nothing)) ed.WriteMessage(vbLf + displStr) Catch ed.WriteMessage(vbLf + "EX 1. " + Err.GetException.ToString) End Try Next End If End If Next End Using Catch ed.WriteMessage(vbLf + "EX 2. " + Err.GetException.ToString) End Try End Sub
@Anonymous wrote:The following code will find solids in your drawing and dump all its properties. The pros are that you can use this method to learn about any autocad object, the cons that you will have to come up with a more robust way to dump them other than ed.WriteMessage because the Editor buffer is simply not large enough to print out all the properties of a complex autocad object. I usually use NLog for this purpose....
I'm afraid this isn't going to help the OP, because solid history properties (like Cyilinder height/radious) are not exposed via any API. There are no managed wrapper properties for them, and for that matter, there are no managed wrapper types for the various primitives (Cylinder, Box, Cone, etc.).
The fact that the OP's question has been ignored by Autodesk personell is also not suprising, as Autodesk has very deliberately witheld basic scripting functionality for 3D solid primitives from their $4K 3D CADD software, and is most-likely a topic which most of them are not permitted to discuss.
Hi Fredrik / DP,
Yes, It would have been easier if there were independent classes representing the different kinds of solids.
There may be some design considerations for the way the class hierarchy is, which I am unaware of.
But at present, "AcDb3dSolid" is a class that represents different kinds of 3d solids and I think it is the same even with the C++ API.
Here is blog post that might help get the properties directly using OPM interfaces :
It is a C++ code but you can use it in a mixed managed project which can then be referenced in your managed project.
HI Belaji.
The 'internal-use-only' classes for history-based Solid primitives all have identifiers starting with AcDbSh*
Here is a small excerpt from an exports dump of acdbxx.dll (showing only the exports for the class that represents a Cylinder).
AcDbShCylinder::AcDbShCylinder(class AcDbSystemInternals *) AcDbShCylinder::AcDbShCylinder(void) class AcRxClass * AcDbShCylinder::desc(void) class AcRxClass * AcDbShCylinder::gpDesc double AcDbShCylinder::height(void) class AcRxClass * AcDbShCylinder::isA(void) bool AcDbShCylinder::isCylindrical(void) bool AcDbShCylinder::isElliptical(void) double AcDbShCylinder::majorRadius(void) double AcDbShCylinder::minorRadius(void) enum Acad::ErrorStatus AcDbShCylinder::setHeight(double) enum Acad::ErrorStatus AcDbShCylinder::setMajorRadius(double) enum Acad::ErrorStatus AcDbShCylinder::setMinorRadius(double) enum Acad::ErrorStatus AcDbShCylinder::setXRadius(double) enum Acad::ErrorStatus AcDbShCylinder::setYRadius(double) double AcDbShCylinder::xRadius(void) double AcDbShCylinder::yRadius(void) AcDbShCylinder::~AcDbShCylinder(void)
Hi,
Maybe you can use the Brep class (Boundary Representation) and get these infos from the edges.
See a simple example here:
http://www.theswamp.org/index.php?topic=31865.msg445372#msg445372
I have tested the boundary representation example. Is there a good way to interpret and recognize something using this? I understand that this may be difficult since a solid3d can have any shape.
I have also looked at Fenton Webbs ObjectARX example linked in this post. I have only used .NET API so I haven't been able to run it, but I see he gets height, length and width. Is it possible to get the type of primitive as well since this is shown in the properties in AutoCAD? (See attached image)
@Anonymous wrote:I have tested the boundary representation example. Is there a good way to interpret and recognize something using this? I understand that this may be difficult since a solid3d can have any shape.
I have also looked at Fenton Webbs ObjectARX example linked in this post. I have only used .NET API so I haven't been able to run it, but I see he gets height, length and width. Is it possible to get the type of primitive as well since this is shown in the properties in AutoCAD? (See attached image)
No, as I mentioned in a previous reply, the classes that represent Solid3d primitives with history are not publicly usable, and there are no other ways short of DXF-style hacking using acdbEntGet()/acdbEntMod() to manipulate or access the primitives and their properites.
This is by design
Can't find what you're looking for? Ask the community or share your knowledge.