- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
To copy dimension value (from drawing) to clipboard
I often need to copy the dimension (of maximum precision) to the clipboard. As this is not possible with the dimension text in the drawing document, once I posted this as an idea.
I recently thought doing this with the help of a iLogic rule. I came up with a code as shown below (it works):
Sub Main() oRule_Index = "iL0015" oRule_Name = "COPY DIMENSION VALUE" oRule_Description = oRule_Index & " - " & oRule_Name MessageBox.Show("@ THE BEGINING OF: " _ & vbLf & "" & oRule_Description _ & vbLf & "", "NOW RUNNING: " & oRule_Index) oModelDoc = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName) 'save text parameter "MyText" value in the string variable Value'Dim Value As String = Parameter(oModelDoc, "Length")'Note: this string Value could be read from any source (e.g., excel sheet). 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 100: Dim oLWT_Array As New ArrayList oLWT_Array.add("Dim-1st") oLWT_Array.add("Dim-2nd") oLWT_Array.add("Dim-3rd") oLWT_Array.add("Dim-4th") oLWT_Array.add("Cancel") oLWT_Array_IP = InputListBox("SELECT FROM ABOVE!", oLWT_Array, oLWT_Array.Item(0), "COPY TO CLIPBOARD", "DIMENSION") If oLWT_Array_IP = "Cancel" Then Exit Sub obj = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingDimensionFilter, "SELECT DIMENSION FOR " & UCase(oLWT_Array_IP)) 'Modelvalue - Returns model value As a Double, In database units (cm) (379.73 cm) 'OverrideModelValue - Returns dimension value As a Double, In database units. (381 cm) '.Text.Text - Returns the actual text As it appears in the box (150 in) '.Text.FormattedText still shows "</DimensionValue>" 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 oDim_ModelValue_mm = oLWT_Array_IP & " " & CStr(oDim.Modelvalue*10) Clipboard.SetText(oDim_ModelValue_mm) MessageBox.Show("Modelvalue in mm (copied to clipboard) is " & oDim_ModelValue_mm, "DIMENION") End If oYN = MessageBox.Show("PASTE IN TO NOTEPAD NOW!" _ & vbLf & "" _ & vbLf & "Do YOU WANT To Continue? ", "Assembly SIZES", MessageBoxButtons.YesNo) If oYN = vbYes Then Goto 100: 'Beep'ThisApplication.Documents.Open(oModelDoc_Dwg, True) End Sub
Just sharing!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thanks for sharing information and iLogic code.
Thanks and regards,
CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thanks for the comments.
I am currently trying to get around a similar situation from within the sketch (master sketch which is huge and composed a great many user parameter).
Need to revise the user parameter at the sketch editing screen.
I posted this before:
Would you provide me with some hint.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hoping that below iLogic code would help to edit user parameter.
Sub Main()
Dim oSelectedDim As DimensionConstraint
oSelectedDim = ThisApplication.Commandmanager.Pick(SelectionFilterEnum.kSketchDimConstraintFilter,"Select a dimension to change dimension")
If oSelectedDim.Parameter.DrivenBy.Count > 0 Then
Dim oUserParam As UserParameter
oUserParam = oSelectedDim.Parameter.DrivenBy.Item(1)
oUserParam.Expression = InputBox("Editing user parameter '" & oUserParam.Name & "'", "Edit user parameter", "10")
Else
MsgBox ("Selected dimension is not contianing any user parameter")
End If
iLogicVb.UpdateWhenDone = True
End Sub
Thanks and regards,
CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network
