I got help from the Inventor Customization Forum. Thanks.
I am getting it done with the rule (need to improve) shown below:
Sub Main()
oModelDoc = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName)
Dim oDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Sheet
oSheet = oDoc.ActiveSheet
Dim oView As DrawingView
'oView = oSheet.DrawingViews.Item(1)
Dim oGeneralDimensions As GeneralDimensions
oGeneralDimensions = oSheet.DrawingDimensions.GeneralDimensions
Dim oSSet As SelectSet = oDoc.SelectSet
If oSSet.Count = 0 Then
MessageBox.Show("Select at least one dimension please", "DIM", _
MessageBoxButtons.OK,MessageBoxIcon.Information)
Exit Sub
Else
i = 0
For Each obj As Object In oSSet
i = i + 1
'filter dimensions, ignore other selected entities
If TypeOf obj Is GeneralDimension Then
'reference to the selected dimension
Dim oDim As GeneralDimension = obj
'refrence to the DimensionText object
Dim oDimensionText As DimensionText = oDim.Text
If i = 1 Then
oCust_iProperty = Length_X
iProperties.Value(oModelDoc, "Custom", oCust_iProperty) = oDimensionText.Text
MessageBox.Show("Cutom iProperty, " & oCust_iProperty & "Updated!", "Title")
End If
End If
Next
End If
'Beep
End Sub
Need help on followings:
1. Need to select the dimension while running the rule (not to run the rule after selecting dimension(s))
2. Need to assign the value of the selected dimension to a user parameter (say, Dim_X1)
Look forward to receiving help!
Thanks.