.NET

Reply
Active Contributor
Fredrik.Larsen
Posts: 46
Registered: ‎11-28-2012
Message 1 of 9 (572 Views)

Solid3d properties

572 Views, 8 Replies
02-27-2013 07:26 AM

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)

Valued Contributor
sszabo
Posts: 86
Registered: ‎09-05-2012
Message 2 of 9 (541 Views)

Re: Solid3d properties

02-28-2013 08:35 AM in reply to: Fredrik.Larsen

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

 

Valued Mentor
DiningPhilosopher
Posts: 370
Registered: ‎05-06-2012
Message 3 of 9 (527 Views)

Re: Solid3d properties

02-28-2013 02:03 PM in reply to: sszabo

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

ADN Support Specialist
Balaji_Ram
Posts: 749
Registered: ‎03-21-2011
Message 4 of 9 (512 Views)

Re: Solid3d properties

02-28-2013 07:45 PM in reply to: Fredrik.Larsen

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 :

http://adndevblog.typepad.com/autocad/2012/05/how-to-obtain-acdb3dsolid-opm-properties-in-autocad-us...

 

It is a C++ code but you can use it in a mixed managed project which can then be referenced in your managed project.

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

Valued Mentor
DiningPhilosopher
Posts: 370
Registered: ‎05-06-2012
Message 5 of 9 (508 Views)

Re: Solid3d properties

02-28-2013 09:07 PM in reply to: Balaji_Ram

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)

 

 

 

 

 

*Expert Elite*
_gile
Posts: 2,133
Registered: ‎04-29-2006
Message 6 of 9 (498 Views)

Re : Solid3d properties

02-28-2013 09:47 PM in reply to: Fredrik.Larsen

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

Gilles Chanteau
Active Contributor
Fredrik.Larsen
Posts: 46
Registered: ‎11-28-2012
Message 7 of 9 (459 Views)

Re : Solid3d properties

03-04-2013 06:38 AM in reply to: _gile

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)

Active Contributor
Fredrik.Larsen
Posts: 46
Registered: ‎11-28-2012
Message 8 of 9 (457 Views)

Re : Solid3d properties

03-04-2013 06:40 AM in reply to: Fredrik.Larsen

* get type of solid

Valued Mentor
DiningPhilosopher
Posts: 370
Registered: ‎05-06-2012
Message 9 of 9 (424 Views)

Re : Solid3d properties

03-06-2013 01:16 AM in reply to: Fredrik.Larsen

Fredrik.Larsen 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

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.