Jeff,
This is strange, I ran your sample and it work like a charm. I paste the same code to a button in the same project add userform hide and show
and I get an error here: Set AlignmentStyle = g_oDocument.AlignmentStyles.Item(0), same as before.
Thanks for your help........I do some checking in different versions, this was to be a half hour project for labeling some marking and it turned out to be more than that.
vba, I'm still working on dot net, it's getting better but I thought this was going to a simple task in vba, faster and it turned out I might of tried it dot given the amout of time I was working on it.
John
Private Sub CommandButton3_Click()
UserForm1.Hide
If (GetCivilObjects() = False) Then
MsgBox "Error accessing Civil 3D!"
Exit Sub
End If
Dim AlignmentsSiteless As AeccAlignmentsSiteless
Dim Alignment As AeccAlignments
Dim Align As AeccAlignment
Dim AlignmentStyle As AeccAlignmentStyle
Dim AlignmentLabelStyleSet As AeccAlignmentLabelStyleSet
Set AlignmentStyle = g_oDocument.AlignmentStyles.Item(0)
'"_Proposed"
Set AlignmentLabelStyleSet = g_oDocument.AlignmentLabelStyleSets.Item(0)
'("_No Labels")
Dim sAlignName As String
Dim sLayerName As String
Dim oPoly As AcadLWPolyline
Dim pt As Variant
Dim obj As AcadObject
ThisDrawing.Utility.GetEntity obj, pt, "Select the Polyline to convert to an Alignment :"
If TypeOf obj Is AcadLWPolyline Then
Set oPoly = obj
Else
MsgBox "Selected Entity is NOT a Pline ! "
End If
Dim dPolyObjId As Long
dPolyObjId = oPoly.ObjectID
sAlignName = "UsingTheAddFromPolylineMethod"
sLayerName = "0"
Set Align = g_oDocument.AlignmentsSiteless.AddFromPolyline(sAlignName, sLayerName, dPolyObjId, AlignmentStyle, AlignmentLabelStyleSet, True, True)
UserForm1.Show
End Sub