AutoCAD 2010/2011/2012

AutoCAD 2010/2011/2012

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

Autocad 2012 with VBA, for 3D volume calculation

1097 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,403
Registered: ‎06-29-2007
Message 2 of 8 (1,096 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,051 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,049 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,403
Registered: ‎06-29-2007
Message 5 of 8 (1,042 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 (1,040 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,403
Registered: ‎06-29-2007
Message 7 of 8 (1,037 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 (1,036 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

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!