Added balloons to frame drawings
This commit is contained in:
parent
ad7dbf49ff
commit
018a381f5d
Binary file not shown.
Binary file not shown.
|
|
@ -38,9 +38,11 @@ Public Class Individual_Frame_Drawing
|
||||||
Dim swApp As SldWorks.SldWorks
|
Dim swApp As SldWorks.SldWorks
|
||||||
swApp = CType(System.Runtime.InteropServices.Marshal.GetActiveObject("SldWorks.Application"), SldWorks.SldWorks)
|
swApp = CType(System.Runtime.InteropServices.Marshal.GetActiveObject("SldWorks.Application"), SldWorks.SldWorks)
|
||||||
|
|
||||||
Dim iAssembly As IAssemblyDoc
|
Dim status As Boolean
|
||||||
Dim swErrors, swWarnings As Integer
|
|
||||||
iAssembly = swApp.OpenDoc6(Individual.filepath & "\Temp\frame_assembly" & 1 & ".SLDASM", 2, 1, "", swErrors, swWarnings) 'FIXA
|
'Dim iAssembly As IAssemblyDoc
|
||||||
|
'Dim swErrors, swWarnings As Integer
|
||||||
|
'iAssembly = swApp.OpenDoc6(Individual.filepath & "\Temp\frame_assembly" & 1 & ".SLDASM", 2, 1, "", swErrors, swWarnings) 'FIXA
|
||||||
|
|
||||||
Dim iDrawing As DrawingDoc
|
Dim iDrawing As DrawingDoc
|
||||||
Dim swSheetWidth As Double
|
Dim swSheetWidth As Double
|
||||||
|
|
@ -55,60 +57,111 @@ Public Class Individual_Frame_Drawing
|
||||||
swSheet.SetTemplateName(Individual.filepath & "\X2021\Weland ritningsmallar\A3 Part.slddrt")
|
swSheet.SetTemplateName(Individual.filepath & "\X2021\Weland ritningsmallar\A3 Part.slddrt")
|
||||||
swSheet.ReloadTemplate(True)
|
swSheet.ReloadTemplate(True)
|
||||||
swSheet.SetScale(1, 10, False, False)
|
swSheet.SetScale(1, 10, False, False)
|
||||||
|
swSheet.SetName("Frame 1")
|
||||||
|
|
||||||
Dim layMgr As LayerMgr
|
Dim layMgr As LayerMgr
|
||||||
layMgr = iDrawing.GetLayerManager()
|
layMgr = iDrawing.GetLayerManager()
|
||||||
Dim status As Boolean
|
|
||||||
status = layMgr.SetCurrentLayer("Svenska")
|
|
||||||
|
|
||||||
Dim myView As View
|
For i = 0 To Individual_Frame_3D.cuttingList.Count - 1
|
||||||
myView = iDrawing.CreateDrawViewFromModelView3(Individual.filepath & "\Temp\frame_assembly" & 1 & ".SLDASM", "*Front", swSheetWidth / 2, swSheetHeight / 2, 0)
|
If i > 0 Then
|
||||||
myView.UseSheetScale() = True
|
status = iDrawing.NewSheet3("Frame" & i + 1, 12, 12, 1, 10, False, Individual.filepath & "\X2021\Weland ritningsmallar\A3 Part.slddrt",
|
||||||
myView.SetDisplayTangentEdges2(2)
|
swSheetWidth, swSheetHeight, "Same as sheet specified in Document Properties")
|
||||||
|
|
||||||
Dim swExtensions As SldWorks.ModelDocExtension
|
|
||||||
swExtensions = iDrawing.Extension
|
|
||||||
Dim RootComp = myView.RootDrawingComponent
|
|
||||||
Dim CompName = RootComp.Name
|
|
||||||
|
|
||||||
Dim OutLine = myView.GetOutline
|
|
||||||
|
|
||||||
For i = 0 To Individual_Frame_3D.cuttingList.ElementAt(0).Value.Count
|
|
||||||
Dim frameComponentName As String
|
|
||||||
If i = Individual_Frame_3D.cuttingList.ElementAt(0).Value.Count Then
|
|
||||||
frameComponentName = "frame_l_end_piece" & i + 1
|
|
||||||
Else
|
|
||||||
frameComponentName = frameComponents(i)("partName")
|
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Dim plane1Name As String = "OffPlane1@" & CompName & "@" & myView.GetName2 & "/" & frameComponentName & "-1@" & CompName.Split("-")(0)
|
status = layMgr.SetCurrentLayer("Svenska")
|
||||||
Dim plane2Name As String = "OffPlane2@" & CompName & "@" & myView.GetName2 & "/" & frameComponentName & "-1@" & CompName.Split("-")(0)
|
|
||||||
|
|
||||||
Dim xOffset As Integer = 0
|
Dim myView As View
|
||||||
For j = 0 To i
|
myView = iDrawing.CreateDrawViewFromModelView3(Individual.filepath & "\Temp\frame_assembly" & i + 1 & ".SLDASM", "*Front", swSheetWidth / 2, swSheetHeight / 2, 0)
|
||||||
If j = Individual_Frame_3D.cuttingList.ElementAt(0).Value.Count Then
|
myView.UseSheetScale() = True
|
||||||
xOffset += (200 - xOffset) / 2
|
myView.SetDisplayTangentEdges2(2)
|
||||||
ElseIf j = i Then
|
|
||||||
xOffset += (Individual_Frame_3D.sideFrameLengths("Frame " & Individual_Frame_3D.cuttingList.ElementAt(0).Value(j)) / 10) / 2
|
Dim swExtensions As SldWorks.ModelDocExtension
|
||||||
|
swExtensions = iDrawing.Extension
|
||||||
|
Dim RootComp = myView.RootDrawingComponent
|
||||||
|
Dim CompName = RootComp.Name
|
||||||
|
|
||||||
|
Dim OutLine = myView.GetOutline
|
||||||
|
|
||||||
|
For j = 0 To Individual_Frame_3D.cuttingList.ElementAt(i).Value.Count
|
||||||
|
Dim frameComponentName As String
|
||||||
|
If j = Individual_Frame_3D.cuttingList.ElementAt(i).Value.Count Then
|
||||||
|
frameComponentName = "frame_l_end_piece" & i + 1
|
||||||
Else
|
Else
|
||||||
xOffset += Individual_Frame_3D.sideFrameLengths("Frame " & Individual_Frame_3D.cuttingList.ElementAt(0).Value(j)) / 10
|
frameComponentName = frameComponents(Individual_Frame_3D.cuttingList.ElementAt(i).Value(j) - 1)("partName")
|
||||||
End If
|
End If
|
||||||
Next
|
|
||||||
xOffset = xOffset / 1000
|
|
||||||
Dim X_Mid = OutLine(2) - 0.005 - xOffset
|
|
||||||
|
|
||||||
iDrawing.ClearSelection2(True)
|
Dim plane1Name As String = "OffPlane1@" & CompName & "@" & myView.GetName2 & "/" & frameComponentName & "-1@" & CompName.Split("-")(0)
|
||||||
|
Dim plane2Name As String = "OffPlane2@" & CompName & "@" & myView.GetName2 & "/" & frameComponentName & "-1@" & CompName.Split("-")(0)
|
||||||
|
|
||||||
|
Dim xOffset As Double = 0
|
||||||
|
For k = 0 To j
|
||||||
|
If k = Individual_Frame_3D.cuttingList.ElementAt(i).Value.Count Then
|
||||||
|
xOffset += (2000 / 10 - xOffset) / 2
|
||||||
|
ElseIf k = j Then
|
||||||
|
xOffset += (Individual_Frame_3D.sideFrameLengths("Frame " & Individual_Frame_3D.cuttingList.ElementAt(i).Value(k)) / 10) / 2
|
||||||
|
Else
|
||||||
|
xOffset += Individual_Frame_3D.sideFrameLengths("Frame " & Individual_Frame_3D.cuttingList.ElementAt(i).Value(k)) / 10
|
||||||
|
End If
|
||||||
|
Next
|
||||||
|
xOffset = xOffset / 1000
|
||||||
|
Dim X_Mid = OutLine(2) - 0.005 - xOffset
|
||||||
|
|
||||||
|
iDrawing.ClearSelection2(True)
|
||||||
Dim measurement As IDisplayDimension
|
Dim measurement As IDisplayDimension
|
||||||
swExtensions.SelectByID2(plane1Name, "PLANE", 0, 0, 0, True, 0, Nothing, 0)
|
status = swExtensions.SelectByID2(plane1Name, "PLANE", 0, 0, 0, False, 0, Nothing, 0)
|
||||||
swExtensions.SelectByID2(plane2Name, "PLANE", 0, 0, 0, True, 0, Nothing, 0)
|
status = swExtensions.SelectByID2(plane2Name, "PLANE", 0, 0, 0, True, 0, Nothing, 0)
|
||||||
measurement = iDrawing.AddHorizontalDimension2(X_Mid, OutLine(3) + 0.005, 0)
|
measurement = iDrawing.AddHorizontalDimension2(X_Mid, OutLine(3) + 0.005, 0)
|
||||||
|
|
||||||
iDrawing.ClearSelection2(True)
|
iDrawing.ClearSelection2(True)
|
||||||
measurement.SetUnits2(False, 0, 1, 0, True, 12)
|
measurement.SetUnits2(False, 0, 1, 0, True, 12)
|
||||||
measurement.CenterText = True
|
measurement.CenterText = True
|
||||||
measurement.SetPrecision3(0, 0, 0, 0)
|
measurement.SetPrecision3(0, 0, 0, 0)
|
||||||
Next
|
|
||||||
|
|
||||||
|
'Balloon
|
||||||
|
Dim balloonStyle As Integer
|
||||||
|
Dim balloonOffset As Double
|
||||||
|
Dim balloonText As String
|
||||||
|
If j < Individual_Frame_3D.cuttingList.ElementAt(i).Value.Count Then
|
||||||
|
balloonStyle = 1
|
||||||
|
balloonOffset = 0.01
|
||||||
|
balloonText = Individual_Frame_3D.cuttingList.ElementAt(i).Value(j)
|
||||||
|
Else
|
||||||
|
balloonStyle = 0
|
||||||
|
balloonOffset = -0.03
|
||||||
|
balloonText = "Obsolete"
|
||||||
|
End If
|
||||||
|
|
||||||
|
Dim worldX As Double = swSheetWidth / 2 + ((2000 / 2) / 10) / 1000 - xOffset
|
||||||
|
status = swExtensions.SelectByRay(worldX, 0.153, 0, 0, 0, -1, 0.0005, 2, False, 0, 0)
|
||||||
|
|
||||||
|
Dim BomBalloonParams As Object
|
||||||
|
BomBalloonParams = swExtensions.CreateBalloonOptions()
|
||||||
|
BomBalloonParams.Style = balloonStyle
|
||||||
|
BomBalloonParams.Size = 2
|
||||||
|
BomBalloonParams.UpperTextContent = 1
|
||||||
|
BomBalloonParams.UpperText = """"
|
||||||
|
BomBalloonParams.ShowQuantity = False
|
||||||
|
BomBalloonParams.QuantityPlacement = 1
|
||||||
|
BomBalloonParams.QuantityDenotationText = "X"
|
||||||
|
BomBalloonParams.QuantityOverride = False
|
||||||
|
Dim myNote = swExtensions.InsertBOMBalloon2(BomBalloonParams)
|
||||||
|
|
||||||
|
Dim noteAnnotation As IAnnotation
|
||||||
|
noteAnnotation = myNote.GetAnnotation()
|
||||||
|
noteAnnotation.SetPosition2(worldX + balloonOffset, 0.13, 0)
|
||||||
|
|
||||||
|
iDrawing.ClearSelection2(True)
|
||||||
|
Dim balloonName As String = myNote.GetName()
|
||||||
|
status = swExtensions.SelectByID2(balloonName & "@Drawing View" & i + 1, "NOTE", 0, 0, 0, False, 0, Nothing, 0)
|
||||||
|
Dim editedNote = swExtensions.EditBalloonProperties2(balloonStyle, 2, 0, balloonText, 0, "", 0, False, 1, "X", 0.001)
|
||||||
|
Next
|
||||||
|
Next
|
||||||
|
|
||||||
|
Dim newName As String
|
||||||
|
newName = Individual.filepath & "\Temp" & "\FrameDrawing" & ".SLDDRW"
|
||||||
|
|
||||||
|
status = iDrawing.SaveAs3(newName, 0, 0)
|
||||||
|
status = iDrawing.SaveAs3(Individual.filepath & "\Temp" & "\FrameDrawing" & ".pdf", 0, 2)
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue