Community
Civil 3D Forum
Welcome to Autodesk’s Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Access Profile from an alignment in VBA

4 REPLIES 4
Reply
Message 1 of 5
c__h
205 Views, 4 Replies

Access Profile from an alignment in VBA

I am trying to access the profiles attached to an alignment.

However, I cannot get the Item to work properly.

The code I am trying to use is:

Dim prof As AeccProfile

prof = AlnS.Profiles.Item(1)

The object works, since AlnS.Profiles.Count give me a correct value. But I cannot get the Item to give me a profile.

Can anybody help me with this please?
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: c__h

What does Count return?
If it's 1 then the Item number will be 0......and since it is an Object you
must use Set prof = .....

wrote in message news:5048698@discussion.autodesk.com...
I am trying to access the profiles attached to an alignment.

However, I cannot get the Item to work properly.

The code I am trying to use is:

Dim prof As AeccProfile

prof = AlnS.Profiles.Item(1)

The object works, since AlnS.Profiles.Count give me a correct value. But I
cannot get the Item to give me a profile.

Can anybody help me with this please?
Message 3 of 5
c__h
in reply to: c__h

Ok, I am not using the "Set prof = ... " so that would be it

What would I set prof to?

Thanks for your help.

<> Oh, and count returns 2, so 1 should work. Message was edited by: honeyman
Message 4 of 5
Anonymous
in reply to: c__h

Using the "Profile-2.dwg" from the tutorials as my example drawing, this
worked for me:

[code]
Option Explicit
Public ogCivilApp As AeccApplication
Public ogCivilDoc As AeccDocument

Sub test()
Dim cvSite As AeccSite
Dim cvAlign As AeccAlignment
Dim cvProf As AeccProfile
If ogCivilApp Is Nothing Then
If Not getCivilObjects Then Exit Sub
End If
Set cvSite = ogCivilDoc.Sites.Item("Site")
Set cvAlign = cvSite.Alignments.Item("Ridge Road")
Set cvProf = cvAlign.Profiles.Item(0)
'Do whatever with the profile
End Sub

''Below function was derived from code posted by Laurie Comerford
Function getCivilObjects() As Boolean
On Error GoTo ErrorHandler
Dim oApp As AcadApplication
Set oApp = ThisDrawing.Application
Const sAppName = "AeccXUiLand.AeccApplication"
Set ogCivilApp = oApp.GetInterfaceObject(sAppName)
If ogCivilApp Is Nothing Then
MsgBox "Error creating " & sAppName & ", exit."
getCivilObjects = False
Exit Function
End If
Set ogCivilDoc = ogCivilApp.ActiveDocument
getCivilObjects = True
Exit Function
ErrorHandler:
MsgBox Err.Description & " in getCivilObjects" & vbCrLf & "Hence unable to
continue ", vbCritical
End Function ' getCivilObjects
[/code]
wrote in message news:5048713@discussion.autodesk.com...
Ok, I am not using the "Set prof = ... " so that would be it

What would I set prof to?

Thanks for your help.

<> Oh, and count returns 2, so 1 should work.

Message was edited by: honeyman
Message 5 of 5
c__h
in reply to: c__h

D'oh! It seems so obvious now. Thanks a lot for that. My forehead was getting a little sore from me banging it against my desk repeatedly.

Thanks again!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report