×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

ACAD - VBA - Extracting 3D objects peoperties

ACAD - VBA - Extracting 3D objects peoperties

ACAD - VBA - Extracting 3D objects peoperties

(OP)
Hello,

I have this routine (see below) which prints to a file the coordinates of polylines and lines selected from the screen.
I would like to enhance this routine by allowing it to get the information from 3D objects. I was not able to find anything on the topic. Is it possible at all?
To be clear, what I want to do is:
"Windows select" or "object by object" select from the screen different 3D objects which might be primitives (or results of 3d objects editing) and print on an ascii file their properties (as if I would "select/rightclick/properties/geometry")
For a sphere that would be Center X/Center Y/Center Z etc.

Please let me know

Tuli


Public Sub SelectionSetInfo()
Dim sset As AcadSelectionSet
Dim ACADObj As Variant
Dim i As Integer
Dim fileid As Integer
Dim startpoint As Variant
Dim endpoint As Variant
Dim coordinates As Variant

'if sset with the name mentioned above already exists - delete it
For Each sset In ThisDrawing.SelectionSets
If sset.Name = ssetname Then
sset.Delete
Exit For
End If
Next sset
'add new sset
Set sset = ThisDrawing.SelectionSets.Add(ssetname)
'ask user to select something
sset.SelectOnScreen
'if there are no selected objects
If sset.Count = 0 Then
MsgBox "You have not selected any object.", , "Error"
sset.Delete
Exit Sub
End If

fileid = 1

'here you can use all sset object properties
'it is important to pay attention on object type
'for example Line object does not have Center Property
'and Circle object does not have EndPoint

'you can not only get some properties but
'set them
'for example you can change object color

For Each ACADObj In sset

Print #fileid, "ID=" & Trim(Str(ACADObj.ObjectID))
Print #fileid, "Name=" & ACADObj.ObjectName
Select Case ACADObj.ObjectName
Case "AcDbLine"
Print #fileid, "AcDbLine"
startpoint = ACADObj.startpoint
endpoint = ACADObj.endpoint
For i = 0 To 2
Print #fileid, "StartPoint(" & Trim(Str(i)) & ")=" & Trim(Str(startpoint(i)))
Next i
For i = 0 To 2
Print #fileid, "EndPoint(" & Trim(Str(i)) & ")=" & Trim(Str(endpoint(i)))
Next i
Case "AcDbPolyline"
Print #fileid, "AcDbPolyLine"
coordinates = ACADObj.coordinates
For i = 0 To UBound(coordinates)
Print #fileid, "Coordinate(" & Trim(Str(i)) & ")=" & Trim(Str(coordinates(i)))
Next i
End Select
ACADObj.color = color

Next ACADObj

Close #fileid

End Sub  
Replies continue below

Recommended for you

RE: ACAD - VBA - Extracting 3D objects peoperties

Hi Tuli,

Check the help files under the Acad3DSolid object - this should get you going.

HTH
Todd

RE: ACAD - VBA - Extracting 3D objects peoperties

(OP)
I might be new to this but which "Help" ?

Here in the forum or in Autocad?

Tx
T

RE: ACAD - VBA - Extracting 3D objects peoperties

Hi Tuli,

The help file from AutoCAD.  Select the help pulldown, and then go to the developers/customization area and look for the AutoCAD VBA section.  Or even easier, in the VBA editor from AutoCAD, just type Acad3DSolid, then place your cursor over it and press F1.

HTH
Todd

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login



News


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close