'DRAWINGcode : 'Check if we have replaced the reference and scaled the drawing already oNumbero = Parameter("Opened") Parameter("Opened") = oNumbero + 1 'MsgBox(Parameter("Opened")) If Parameter("Opened") > 2 Then Return End If 'Read in File name - For reference oRead = System.IO.File.OpenText("C:\TempPath\part.txt") EntireFile = oRead.ReadLine() oRead.Close() oPartPath = EntireFile 'Replace Drawing Reference doc = ThisDoc.Document Dim oFileDesc As FileDescriptor oFileDesc = doc.ReferencedFileDescriptors(1).DocumentDescriptor.ReferencedFileDescriptor oFileDesc.ReplaceReference(oPartPath) doc.Update() 'Read in new name for Drawing oRead = System.IO.File.OpenText("C:\TempPath\" & ThisDoc.FileName & ".txt") EntireFile1 = oRead.ReadLine() oRead.Close() oDrawingName = EntireFile1 'Save this drawing 'Add bendnotes Dim oDoc As DrawingDocument Dim oSheet As Sheet Dim oView As DrawingView Dim oCurve As DrawingCurve Dim oBendNote As BendNote oDoc = ThisApplication.ActiveDocument oSheet = oDoc.ActiveSheet For Each oView In oSheet.DrawingViews For Each oCurve In oView.DrawingCurves If oCurve.EdgeType = Inventor.DrawingEdgeTypeEnum.kBendDownEdge _ Or oCurve.EdgeType = Inventor.DrawingEdgeTypeEnum.kBendUpEdge Then ' Create the bend note oBendNote = oSheet.DrawingNotes.BendNotes.Add(oCurve) End If Next 'oCurve Next 'oView 'Scale the Drawing - Note your drawing views names("VIEW1")&("VIEW4") must match the template ViewWidth1 = ActiveSheet.View("VIEW1").Width ViewHeight1 = ActiveSheet.View("VIEW1").Height ViewAve = ((ViewWidth1 + ViewHeight1)/2) If (ViewHeight1 - ViewWidth1) > (.65 * ViewHeight1) Then ViewAve = (ViewAve * 1.5) Else If (ViewWidth1 - ViewHeight1) > (.65 * ViewWidth1) Then ViewAve = (ViewAve * 1.05) End If oScale1 = (4.1/ViewAve) oScale2 = (4.1/(ViewAve*1.45)) oDrawDoc = ThisApplication.ActiveDocument Dim oRef as Document oRef = oDrawDoc.ReferencedDocuments.Item(1) ActiveSheet.View("VIEW1").Scale = oScale1 ActiveSheet.View("VIEW2").Scale = oScale2 oDrawDoc = ThisApplication.ActiveDocument oRef = oDrawDoc.ReferencedDocuments.Item(1) Dim oMaterial As String oMaterial = oRef.ActiveMaterial.DisplayName Dim oThick As String oThick = oRef.PropertySets.Item(4).Item("Thickness").Value oThick2 = (oThick * 2.54) Select Case oThick2 Case 0.63 To 0.64 Gauge_Name = "0.25" Case 0.149 To 0.159 Gauge_Name = "16 Gauge" Case 0.185 To 0.195 Gauge_Name = "14 Gauge" Case 0.28 To 0.35 Gauge_Name = "11 Gauge" Case 0.9 To 0.99 Gauge_Name = "0.375" Case 0.42 To 0.52 Gauge_Name = "7 Gauge" Case Else Gauge_Name = "Other" End Select Dim New_Folder As String = ThisDoc.Path Dim AsmName As String AsmName = oRef.PropertySets.Item(4).Item("AssemblyName").Value strNew = New_Folder & "\" & "Drawings " & AsmName & "\" & Gauge_Name & " " & oMaterial New_Name = ThisDoc.FileName ThisDoc.Document.SaveAs(strNew & "\" & New_Name & ".idw",(True)) If Parameter("Opened") >= 2 Then ThisDoc.Document.Close(True) Else End If sFile = New_Folder & "\" & New_Name & ".dwg" Try My.computer.FileSystem.deleteFile(sFile) Catch MessageBox.Show(sFile & vbLf & " . . . can not delete file, or file not found.", "iLogic") End Try