POST
|
I figured it out today. I finally noticed that when I manually set the graphic to the 10% crosshatch and then examined the symbol properties deeper, the symbol type was a Line Fill Symbol. On the other hand, the Add Graphic To Map snippet uses a Simple Fill Symbol. I had modified the snippet code to set the SimpleFillStyle to crosshatch (again, this displayed in ArcMap fine - the problem was that when exporting the map to a pdf or printing the map, the crosshatch pattern didn't come through and instead the polygon had a solid fill). I then found Create Line Fill Symbol snippet and changed the Add Graphic To Map snippet to use a LineFillSymbol instead a SimpleFillSymbol for my graphic. My original code created a graphic polygon with a crosshatch - the modified code creates a graphic polygon with a single diagonal line, but that's good enough to test if this fixes the problem, and IT DOES! Code is shown below . Public Sub AddGraphicToMap(ByVal map As ESRI.ArcGIS.Carto.IMap, ByVal geometry As ESRI.ArcGIS.Geometry.IGeometry, ByVal rgbColor As ESRI.ArcGIS.Display.IRgbColor, ByVal outlineRgbColor As ESRI.ArcGIS.Display.IRgbColor) Dim graphicsContainer As ESRI.ArcGIS.Carto.IGraphicsContainer = CType(Map, ESRI.ArcGIS.Carto.IGraphicsContainer) Dim element As ESRI.ArcGIS.Carto.IElement = Nothing If (geometry.GeometryType) = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint Then ' Marker symbols Dim simpleMarkerSymbol As ESRI.ArcGIS.Display.ISimpleMarkerSymbol = New ESRI.ArcGIS.Display.SimpleMarkerSymbolClass() simpleMarkerSymbol.Color = rgbColor simpleMarkerSymbol.Outline = True simpleMarkerSymbol.OutlineColor = outlineRgbColor simpleMarkerSymbol.Size = 15 simpleMarkerSymbol.Style = ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle Dim markerElement As ESRI.ArcGIS.Carto.IMarkerElement = New ESRI.ArcGIS.Carto.MarkerElementClass() markerElement.Symbol = simpleMarkerSymbol element = CType(markerElement, ESRI.ArcGIS.Carto.IElement) ElseIf (geometry.GeometryType) = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline Then ' Line elements Dim simpleLineSymbol As ESRI.ArcGIS.Display.ISimpleLineSymbol = New ESRI.ArcGIS.Display.SimpleLineSymbolClass() simpleLineSymbol.Color = rgbColor simpleLineSymbol.Style = ESRI.ArcGIS.Display.esriSimpleLineStyle.esriSLSSolid simpleLineSymbol.Width = 5 Dim lineElement As ESRI.ArcGIS.Carto.ILineElement = New ESRI.ArcGIS.Carto.LineElementClass() lineElement.Symbol = simpleLineSymbol element = CType(lineElement, ESRI.ArcGIS.Carto.IElement) ElseIf (geometry.GeometryType) = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon Then ''ORIGINAL AddGrahpicToMap code '' Polygon elements 'Dim simpleFillSymbol As ESRI.ArcGIS.Display.ISimpleFillSymbol = New ESRI.ArcGIS.Display.SimpleFillSymbolClass() 'simpleFillSymbol.Color = rgbColor 'simpleFillSymbol.Style = ESRI.ArcGIS.Display.esriSimpleFillStyle.esriSFSDiagonalCross 'Dim fillShapeElement As ESRI.ArcGIS.Carto.IFillShapeElement = New ESRI.ArcGIS.Carto.PolygonElementClass() 'fillShapeElement.Symbol = simpleFillSymbol 'element = CType(fillShapeElement, ESRI.ArcGIS.Carto.IElement) ''MODIFIED to use LineFillSymbol instead of SimpleFillSymbol ' Create the Line Symbol to be used Dim cartographicLineSymbol As ESRI.ArcGIS.Display.ICartographicLineSymbol = New ESRI.ArcGIS.Display.CartographicLineSymbolClass With cartographicLineSymbol .Cap = ESRI.ArcGIS.Display.esriLineCapStyle.esriLCSButt .Join = ESRI.ArcGIS.Display.esriLineJoinStyle.esriLJSMitre .Color = rgbColor .Width = 0.5 End With ' Create the LineFillSymbol Dim lineFillSymbol As ESRI.ArcGIS.Display.ILineFillSymbol = New ESRI.ArcGIS.Display.LineFillSymbolClass With lineFillSymbol .Angle = 45 .Separation = 10 .Offset = 5 End With lineFillSymbol.LineSymbol = cartographicLineSymbol Dim fillShapeElement As ESRI.ArcGIS.Carto.IFillShapeElement = New ESRI.ArcGIS.Carto.PolygonElementClass() fillShapeElement.Symbol = lineFillSymbol element = CType(fillShapeElement, ESRI.ArcGIS.Carto.IElement) End If If Not (element Is Nothing) Then element.Geometry = geometry graphicsContainer.AddElement(element, 0) End If End Sub
... View more
07-24-2014
02:13 PM
|
1
|
1
|
553
|
POST
|
I create a graphic on the map (not layout) using ArcObjects. It is a polygon with a gray cross-hatch fill. When I export the layout to pdf manually or through code, the graphic exports as a solid gray polygon. (I'm using the AddGraphicToMap snippet to create the graphic and the ExportActiveView sample to export to pdf). If I manually select the graphic on the map, go to its properties and set the symbol to the 10% Crosshatch symbol in the symbol selector and then export to pdf, the graphic exports correctly. I've found a few suggestions to do things like set the default printer page size to a larger size before exporting, but nothing I've found in my searches has had any effect on the ability to export this graphic correctly. Can anyone help me with this? Thanks.
... View more
07-22-2014
03:01 PM
|
0
|
2
|
3875
|
POST
|
I laughed out loud when I read your second paragraph! And I realized I included the wrong link above - this is the link to the PrintActiveView sample. http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/Sample_Print_active_view/0001000002ms000000/ Have a great rest of your day.
... View more
07-17-2014
10:06 AM
|
0
|
0
|
1043
|
POST
|
I'm using the ExportActiveView sample code to send a layout to a user-selected printer. The dataframe includes a cross-hatched graphic that is added by code. I have two issues: 1. When I print to the printer I have here, the graphic shows up on the printed paper. When my user at another office does the same with his printer, the graphic doesn't print at all. 2. On my printed copy (and a pdf-export from code as well), the graphic shows up as a gray rectangle when on the screen it appears as a cross-hatched rectangle with a tranparent background. If I manually print or export directly from ArcMap, the graphic has the right symbology. I've seen similar questions on these forums but finding them again is not the easiest thing to do these days...
... View more
07-17-2014
09:55 AM
|
0
|
2
|
2691
|
POST
|
Sorry - I was in a hurry when I wrote that and should have included more information. I see now that my question itself didn't say anything about coding. Since PrintAndExport is an ArcObjects CoClass name and I included that in the subject line, I thought it would be understood that it was a coding question. I'll be more aware of being more clear in the future. I should have included this in my earlier response as well - the line of code is from the ExportToActiveView ArcObjects sample found here: http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//000100000026000000
... View more
07-17-2014
08:46 AM
|
0
|
2
|
1043
|
POST
|
No, I meant printing from code (isn't this an ArcObjects.Net discussion group?) I found the answer - I was making it much harder than it needed to be. All I had to do was this: paper.PrinterName = strPrinterName where strPrinterName is the name of the printer I want to print to, which may or may not be the default printer.
... View more
07-15-2014
02:29 PM
|
0
|
4
|
1043
|
POST
|
I can find examples of printing to the default printing but am having a difficult navigating the new site to find an example of printing a map layout to a user-selected printer that is not the default printer. Can someone please help me with this? Thanks!
... View more
07-14-2014
07:05 AM
|
0
|
6
|
3220
|
POST
|
I've created a graphic polygon that is actually a polygon with the center cut out (I created it using ITopologicalOperator.Difference to remove the smaller polygon from the larger one). Now I want the labels on my map to display in the cutout area of my polygon. I found a suggestion to set IBarrierProps.Weight on my graphics layer and tried setting the weight to 0 hoping that the labels would then display but no luck. Any suggestions for me?
... View more
07-01-2014
10:33 AM
|
0
|
0
|
813
|
POST
|
Thanks Neil and Robby for your help. I marked Robby's response as the answer because it provided a little more information if someone else looks at this thread later (I had already created a polygon from the envelope, but it's probably good to note that in the answer.)
... View more
06-30-2014
05:54 AM
|
0
|
0
|
5686
|
POST
|
I have two polygon geometries - one is a polygon from a feature and the other is created from the current view extent (which is always the larger polygon, if that matters). I want to subtract the feature polygon from the view extent polygon, creating a polygon with a donut hole in it. Is there a simple way to do this? I'm using VB.net. Thanks for any advice.
... View more
06-26-2014
01:52 PM
|
0
|
3
|
8552
|
POST
|
Duncan, you were right. I was missing the _Event in the interface name. That took care of the error message I was getting that prevented a successful build. It took me a few more minutes to realize that I forgot to make the same change in the m_appStatusEvents = line. Here's what I have now: Private m_appStatusEvents As IApplicationStatusEvents_Event Protected Overrides Sub OnStartup() m_appStatusEvents = TryCast(My.ThisApplication, IApplicationStatusEvents_Event) AddHandler m_appStatusEvents.Initialized, AddressOf OnInitialized End Sub Private Sub OnInitialized() clsGlobals.intUserRole = 0 If clsGlobals.intUserRole <= 1 Then 'readonly user HideButtons() End If End Sub Private Sub HideButtons() Dim UID As New ESRI.ArcGIS.esriSystem.UID Dim commandItem As ESRI.ArcGIS.Framework.ICommandItem UID.Value = My.ThisAddIn.IDs.btnPushToGeo commandItem = My.ArcMap.Application.Document.CommandBars.Find(UID, False, False) commandItem.Delete() UID.Value = My.ThisAddIn.IDs.tolCreateNew commandItem = My.ArcMap.Application.Document.CommandBars.Find(UID, False, False) commandItem.Delete() UID.Value = My.ThisAddIn.IDs.btnUpdateOutfallSV commandItem = My.ArcMap.Application.Document.CommandBars.Find(UID, False, False) commandItem.Delete() End Sub (I've removed other code that OnInititalized will execute to determine the user role and assume for now that these buttons always get hidden. If I can get this part to work, I will add the extra code back in). Here's the result: 1. Open ArcMap and show toolbar - all buttons are visible. 2. Leave toolbar open, close ArcMap, open ArcMap - buttons are hidden. 3. Close toolbar, close ArcMap - back to behavior number 1. So, as long as ArcMap is closed with the toolbar visible, the buttons are hidden when ArcMap is re-opened. Whenever the toolbar needs to be opened by the user, the buttons are not hidden. I guess I don't understand when OnInitialized actually gets run. But the AcmeExt example has a bunch of other checks going on to test whether Startup has run, etc. so I guess it's time to go back to that sample and keep expanding my code. Unfortunately, I'm no longer being paid to figure this out and the client was OK with the addin as delivered. Thanks again for all of your help.
... View more
07-05-2013
08:10 AM
|
0
|
1
|
208
|
POST
|
Thanks for continuing to try to figure this out, Duncan. I looked at the code at the link you included but got stuck when I couldn't get the Initialized event setup correctly using the following: m_appStatusEvents = TryCast(My.ThisApplication, IApplicationStatusEvents) AddHandler m_appStatusEvents.Initialized, AddressOf OnInitialized I get an error that 'Initialized is not an event of ESRI.ArcGIS.Framework.IApplicationStatusEvents', even though when I use the Object Browser to look at IApplicationStatusEvents, it clearly lists Initialized. At this point, I need to get something to the client and they are OK with it working the way it is, which isn't perfect but does work once the user opens a map file. Thanks for all your help. Terese
... View more
07-02-2013
09:21 AM
|
0
|
0
|
1053
|
POST
|
Because we have read-only users and higher-levell users. The read-only users don't get the buttons, the other users do. Note the line of code: Private Sub OpenOrNewDocument() 'hide buttons/tools for readonly user If clsGlobals.intUserRole > 1 Then Exit Sub 'not read only user
... View more
06-28-2013
11:47 AM
|
0
|
0
|
1053
|
POST
|
One more update. I kind of have it working. I added an extension to my addin and set the OnStartup code as follows: AddHandler My.ArcMap.Events.OpenDocument, AddressOf OpenOrNewDocument AddHandler My.ArcMap.Events.NewDocument, AddressOf OpenOrNewDocument The OpenOrNewDocument Sub is as follows: Private Sub OpenOrNewDocument() 'hide buttons/tools for readonly user If clsGlobals.intUserRole > 1 Then Exit Sub 'not read only user Dim UID As New ESRI.ArcGIS.esriSystem.UID Dim commandItem As ESRI.ArcGIS.Framework.ICommandItem UID.Value = My.ThisAddIn.IDs.btnPushToGeo commandItem = My.ArcMap.Application.Document.CommandBars.Find(UID, False, False) commandItem.Delete() UID.Value = My.ThisAddIn.IDs.tolCreateNew commandItem = My.ArcMap.Application.Document.CommandBars.Find(UID, False, False) commandItem.Delete() End Sub I tried putting the code to hide the buttons in the OnStart routine of the extension, but ArcMap crashes with no error messages reported. This way my code is triggered when the user opens a map or goes to a new map. The first time the toolbar is turned on, all the buttons are visible (but I have them disabled). If the user then opens an mxd, goes to a new one or closes and re-opens ArcMap (without closing the toolbar), the buttons/tools that should be hidden are hidden and stay hidden unless the user closes the toolbar and re-opens it. If anyone reading this can tell me where to better implement this code so that it is executed when the toolbar is created, I would appreciate it.
... View more
06-28-2013
10:45 AM
|
0
|
0
|
1053
|
POST
|
OK, I just did another test. I created another button on the toolbar and put the following code in OnClick: Try Dim commandBars As ESRI.ArcGIS.Framework.ICommandBars = clsGlobals.app.Document.CommandBars Dim barID As ESRI.ArcGIS.esriSystem.UID = New ESRI.ArcGIS.esriSystem.UIDClass barID.Value = "Test_Toolbar" Dim barItem As ESRI.ArcGIS.Framework.ICommandItem = commandBars.Find(barID, False, False) If (barItem Is Nothing) OrElse barItem.Type <> ESRI.ArcGIS.Framework.esriCommandTypes.esriCmdTypeToolbar Then Exit Sub Dim commandBar As ESRI.ArcGIS.Framework.ICommandBar = CType(barItem, ESRI.ArcGIS.Framework.ICommandBar) Dim commandID As ESRI.ArcGIS.esriSystem.UID = New ESRI.ArcGIS.esriSystem.UIDClass commandID.Value = "Test_Button" If Not commandBar.Find(commandID, False) Is Nothing Then MsgBox("button found") Dim cmd As ESRI.ArcGIS.Framework.ICommandItem = commandBar.Find(commandID, False) cmd.Delete() End If Catch ex As Exception MessageBox.Show(ex.Message) End Try When I click the new button on the toolbar, the button referenced in the code disappears. So the question is, where do I run this code from so I don't have to click a button to get the other button to delete?
... View more
06-28-2013
09:37 AM
|
0
|
0
|
1053
|
Title | Kudos | Posted |
---|---|---|
1 | 05-09-2013 04:50 PM | |
1 | 07-24-2014 02:13 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|