- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
As company policy, I need to help users export drawing as JPG for another department. However, when I test printing JPG file, all red, green, and blue line looks light gray color. Since there is no function like as "PrintAllColorsAsBlack" before I use "SaveAsJPG". I found a way to solve it that was change all layers to black and lineweight bigger. It seems good.
But, I want to recover all layer colors and lineweights back after saving JPG. So, I tried to use array to save all layer colors at the beginning, and write it back at the end. However, I failed many times. Although I can just discard saving, someone may save it accidentally. So, I want to avoid this mistake in advance. I am just a beginner of using iLogic. Is there anyone can help me about this request? I need help for part1 and part4 in the following?
Thanks so much.
[Workflow]
Part1: Save the beginning layer color
Part2: Change all layers color to black and lineweight=0.25
Part3: Save to JPG
Part4: Recover the beginning color of layers
Sub Main Dim drawdoc As DrawingDocument = ThisApplication.ActiveDocument Dim oLayers As LayersEnumerator oLayers = drawdoc.StylesManager.Layers 'Part1: Save all current color of layers 'NEED HELP ' ' ' 'Part2: Make all layers color black Dim oColor As Color oColor = ThisApplication.TransientObjects.CreateColor(0, 0, 0) Dim oLayer As Layer For Each oLayer In oLayers 'oLayer.Color = oColor oLayer.LineWeight = 0.25 Next 'Part3: Save to JPG oSheetName = ActiveSheet.Name oSheetName = oSheetName.Replace(":","_P") oPartnumber = iProperties.Value("Project", "Part Number") oF_Path = "P:\JPG\" & DateString & "\" & oPartnumber & "(" & oSheetName & ")" SaveAsJPG(oF_Path & ".jpg", 3000) 'Part4: Recover the beginning color of layers 'NEED HELP ' ' ' End Sub
Public Sub SaveAsJPG(oPath As String, oWidth As Integer) Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument Dim oSheet As Sheet = oDoc.ActiveSheet Dim oView As Inventor.View = ThisApplication.ActiveView Dim dAspectRatio As Double = oSheet.Height / oSheet.Width ' Adjust the aspect ratio of the view to match that of the sheet oView.Height = oView.Width * dAspectRatio Dim oCamera As Camera = oView.Camera ' Center the sheet to the view oCamera.Fit ' Zoom to fit the sheet exactly within the view ' Add some tolerance to make sure the sheet borders are contained oCamera.SetExtents(oSheet.Width * 1.003, oSheet.Height * 1.003) ' Apply changes to the camera oCamera.Apply ' Save view to jpg. Make sure that the aspect ratio is maintained when exporting oView.SaveAsBitmap(oPath, oWidth, oWidth * dAspectRatio) ' Restore the view oCamera.Fit oCamera.Apply oView.WindowState = kMaximize End Sub
Solved! Go to Solution.