AutoCAD 2010/2011/2012

AutoCAD 2010/2011/2012

Reply
Contributor
ozkan_0712
Posts: 19
Registered: ‎03-18-2012
Message 1 of 8 (1,048 Views)
Accepted Solution

Autocad 2012 with VBA, for 3D volume calculation

1048 Views, 7 Replies
04-14-2012 09:31 AM

Hi everbody,

 

I need a help with Autocad 2012 with VBA (Visual Basic for Application),

 

I want to measure some solid objects volumes (3D).

All my objects were put different layers.  Every layers have got one object.

Which classes should I use?

Thanks for helps....

Hi,

 

>> Which classes should I use?

Do you mean "which references"? Then the default references for AutoCAD that are already referenced when you start a new VBA-project.

 

Check this:

Public Sub ScanForSolids_Output_Volume()
Dim tEnt As AcadEntity
For Each tEnt In ThisDrawing.ModelSpace
If TypeOf tEnt Is Acad3DSolid Then
Dim tEntSolid As Acad3DSolid
Set tEntSolid = tEnt
ThisDrawing.Utility.Prompt (vbCrLf & "SOLID: handle: &h" & tEntSolid.Handle & " / volume: " & tEntSolid.Volume)
End If
Next
End Sub

 

BTW: there is a special forum for >>>VBA with AutoCAD<<<

 

- alfred -

*Expert Elite*
Alfred.NESWADBA
Posts: 9,071
Registered: ‎06-29-2007
Message 2 of 8 (1,047 Views)

Re: Autocad 2012 with VBA, for 3D volume calculation

04-14-2012 09:58 AM in reply to: ozkan_0712

Hi,

 

>> Which classes should I use?

Do you mean "which references"? Then the default references for AutoCAD that are already referenced when you start a new VBA-project.

 

Check this:

Public Sub ScanForSolids_Output_Volume()
   Dim tEnt As AcadEntity
   For Each tEnt In ThisDrawing.ModelSpace
      If TypeOf tEnt Is Acad3DSolid Then
         Dim tEntSolid As Acad3DSolid
         Set tEntSolid = tEnt
         ThisDrawing.Utility.Prompt (vbCrLf & "SOLID: handle: &h" & tEntSolid.Handle & " / volume: " & tEntSolid.Volume)
      End If
   Next
End Sub

 

BTW: there is a special forum for >>>VBA with AutoCAD<<<

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Contributor
ozkan_0712
Posts: 19
Registered: ‎03-18-2012
Message 3 of 8 (1,002 Views)

Re: Autocad 2012 with VBA, for 3D volume calculation

04-22-2012 04:47 AM in reply to: Alfred.NESWADBA

Thanks for helps.

 

I wrote you codes, it is working very well.

 

Bu t I wanna sequence my solid objects  in descending order  from big to small.

 

Has Acad3DSolid got any class that I can use in descending order?

 

thanks for helps..

 

 

New Member
4208401
Posts: 1
Registered: ‎04-22-2012
Message 4 of 8 (1,000 Views)

Re: Autocad 2012 with VBA, for 3D volume calculation

04-22-2012 05:23 AM in reply to: ozkan_0712

Thanks for post.. it is working very well.

I have the same question has Acad3DSolid got any class that I can use in descending order?

 

thanks for helps..

*Expert Elite*
Alfred.NESWADBA
Posts: 9,071
Registered: ‎06-29-2007
Message 5 of 8 (993 Views)

Re: Autocad 2012 with VBA, for 3D volume calculation

04-22-2012 11:18 AM in reply to: ozkan_0712

Hi,

 

Sorry, I overlooked this thread, so my answer is real late. :smileysad:

 

>> Has Acad3DSolid got any class that I can use in descending order?

Acad3DSolid is no object that has any sortling capabilities (as it can't hold list of <anything>).

So it's up to you to put them do a collection/list/.... and sort by yourself.

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Contributor
ozkan_0712
Posts: 19
Registered: ‎03-18-2012
Message 6 of 8 (991 Views)

Re: Autocad 2012 with VBA, for 3D volume calculation

04-22-2012 12:49 PM in reply to: ozkan_0712

Many many thanks for helps..

 

But I wonder Where can I learn  AcadSolids references?

 

I am a .NET user.  While you are working with C sharp, If you get mouse icon on any program code (objects), you can see all references about it.

 

As far as I'm concerned Acadsolid is hidden box or close box forme.  Where can I learn this object's references?

 

Thanks for helping,,

 

Best 

*Expert Elite*
Alfred.NESWADBA
Posts: 9,071
Registered: ‎06-29-2007
Message 7 of 8 (988 Views)

Re: Autocad 2012 with VBA, for 3D volume calculation

04-22-2012 12:53 PM in reply to: ozkan_0712

Hi,

 

I'm not sure to understand your question "Where can I learn  AcadSolids references?" really.

Anyway: please see the difference between "AcadSolid" and "Acad3DSolid", that are totally different things!

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Contributor
ozkan_0712
Posts: 19
Registered: ‎03-18-2012
Message 8 of 8 (987 Views)

Re: Autocad 2012 with VBA, for 3D volume calculation

04-22-2012 12:56 PM in reply to: Alfred.NESWADBA

sorry...

 

I want to say Acad3Dsolid references. Or I can say all model name spaces for VBA

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.