Message 1 of 2
LWH (Length Width an Height) from within drawing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
We need to incorporate length, width and height in the drawing document mostly for all part, assembly and general arrangement (or erection) drawings. The following rule can be tailored to suit to achieve these objectives.
Sub Main() 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: oYN = MessageBox.Show("DO YOU WANT TO CONTINUE? ", "ASSEMBLY SIZES", MessageBoxButtons.YesNo) If oYN = vbYes Then Dim oLWT_Array As New ArrayList oLWT_Array.add("Length") oLWT_Array.add("Width") oLWT_Array.add("Height") oLWT_Array.add("Thickness") oLWT_Array.add("Cancel") oLWT_Array_IP = InputListBox("SELECT FROM ABOVE!", oLWT_Array, oLWT_Array.Item(0), "OVER ALL SIZES", "OPTIONS") If oLWT_Array_IP = "Cancel" Then Exit Sub obj = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingDimensionFilter, "SELECT DIMENSION FOR " & UCase(oLWT_Array_IP)) 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 oTxt_SizeOA = oDimensionText.Text oYN = MessageBox.Show("ASSM_" & UCase(oLWT_Array_IP) & " IS " _ & vbLf & "" & oTxt_SizeOA _ & vbLf & "" _ & vbLf & "DO YOU WANT TO EDIT?", "CUSTOM iPROPERTY FOR", MessageBoxButtons.YesNo) If oYN = vbYes Then oTxt_SizeOA = InputBox("Edit if necessary: ", oLWT_Array_IP, oTxt_SizeOA) End If If oLWT_Array_IP = oLWT_Array(0) Then iProperties.Value(oModelDoc, "Custom", "ASSM_LENGTH") = oTxt_SizeOA If oLWT_Array_IP = oLWT_Array(1) Then iProperties.Value(oModelDoc, "Custom", "ASSM_WIDTH") = oTxt_SizeOA If oLWT_Array_IP = oLWT_Array(2) Then iProperties.Value(oModelDoc, "Custom", "ASSM_HEIGHT") = oTxt_SizeOA MessageBox.Show("Cutom iProperty: " & oLWT_Array_IP & " - Updated!", oLWT_Array_IP) End If Goto 100: Else If oYN = vbNo Then 'Do nothing End If iLogicVb.UpdateWhenDone = True 'Beep 'ThisApplication.Documents.Open(oModelDoc_Dwg, True) End Sub Sub oCreate_LWH_iProperties() oModelDoc = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName) 'oCustomPropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties") 'oCustomPropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties") Dim oCustiProperties_Array As New ArrayList oCustiProperties_Array.add("ASSM_LENGTH") oCustiProperties_Array.add("ASSM_WIDTH") oCustiProperties_Array.add("ASSM_HEIGHT") For i = 0 To oCustiProperties_Array.Count-1 Try 'set property value oModelDoc.PropertySets.Item("Inventor User Defined Properties").Item(oCustiProperties_Array(i)).Value = CStr(i) Catch ' Assume error means not found so create it iProperties.Value(oModelDoc, "Custom", oCustiProperties_Array(i)) = "Test - " & CStr(i) 'MessageBox.Show(oCustiProperties_Array(i) & ": Exists", "Title") End Try Next iLogicVb.UpdateWhenDone = True End Sub