How to access object properties in VBA?

How to access object properties in VBA?

Anonymous
Not applicable
2,662 Views
6 Replies
Message 1 of 7

How to access object properties in VBA?

Anonymous
Not applicable

I made a slice in a point cloud and now I want to change its position with VBA-code. It's position is in the properties. How can I retrieve and modify the desired properties in VBA?

Thank you in advance,

A newbie Autocad VBA programmer

0 Likes
Accepted solutions (1)
2,663 Views
6 Replies
Replies (6)
Message 2 of 7

Ed__Jobe
Mentor
Mentor

How did you create the slice? Is it a standard Section object?

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 3 of 7

Anonymous
Not applicable

Hi @Ed__Jobe 

 

I used the command 'sectionplane' on a rcp-pointcloud. Here I have selected the type: 'slice'. This is shown in the image below.

I also marked 'Section Offset' in properties. This is the value that I want to be able to modify via VBA.

 

Section of a pointcloudSection of a pointcloud

0 Likes
Message 4 of 7

Ed__Jobe
Mentor
Mentor

That creates a vba Section object. You can edit the Section.SectionPlaneOffset property. Once you have the user select the section, set a variable of Section type and then access it's properties.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 5 of 7

Anonymous
Not applicable

hi @Ed__Jobe 

Thank you for your answer.

How would I encode that?

Kind regards

0 Likes
Message 6 of 7

Ed__Jobe
Mentor
Mentor
Accepted solution

Here you go.

Sub SectionTest()
    Dim sec As AcadSection
    Dim oEnt As AcadEntity
    Dim pp As Variant
    
GetEnt:
    ThisDrawing.Utility.getEntity oEnt, pp, "Select an Section object: "
    
    If TypeOf oEnt Is AcadSection Then
        Set sec = oEnt
        sec.SectionPlaneOffset = 120
    Else
        ThisDrawing.Utility.Prompt "You didn not select a Section object. Try again. "
        GoTo GetEnt
    End If
    
End Sub

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Message 7 of 7

Anonymous
Not applicable

It's working perfectly. Thank you very much @Ed__Jobe !

0 Likes