POST
|
My issue is that I don't want the Layout to become a part of the Project at all - I just want the in-memory Layout object.
... View more
01-10-2020
01:29 PM
|
0
|
0
|
545
|
POST
|
I would like to be able import a Layout from a PAGX file without actually adding it to the Project's set of ProjectItems. Is this possible? Thus far, the only way I have found to import from PAGX programatically (and grab the recently added Layout) is to do something like this: Item importedProjectItem = GetImportedLayoutProjectItem(workingDirectoryPath);
await QueuedTask.Run(() =>
{
List<LayoutProjectItem> layoutProjectItemsBeforeImport = Project.Current.GetItems<LayoutProjectItem>().ToList();
Project.Current.AddItem((IProjectItem)importedProjectItem);
LayoutProjectItem importedLayoutProjectItem = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(item => !layoutProjectItemsBeforeImport.Contains(item));
}
}); Of course, the call to Project.Current.AddItem() adds the Layout to the Project, which automatically brings up the Layout for editing in the GUI. I have tried casting the Item in various places, and that never works - It seems that an actual LayoutProjectItem is not created - and thus the Layout object itself is not created - until the call to AddItem(). But is there a way to create a Layout object from a PAGX file without going through these steps?
... View more
01-10-2020
12:38 PM
|
0
|
2
|
616
|
POST
|
I'm working on an Add-In that needs to read spatial data from a feature service. Using just a feature service URL, this seems to be working. I can create a Geodatabase object from connection properties derived from the feature service's URI, and then I can get data out of that gdb's tables. But what if I need to access data from a specific version of a versioned feature service? Right now, IsVersioningSupported() always returns false from a Geodatabase instantiated from a feature service's connection properties. Likewise, if I try to call GetVersionManager() on that Geodatabase object, I get the following error: "This type of geodatabase (Service) does not support version." Does this really mean there is no way to programatically access versions of a versioned feature service? Or does it just mean that the feature service in question isn't set up properly for versioning? Ultimately I'm hoping to find out 1. How to set up a feature service for traditional and branch versioning 2. How to access those versions within the Arc Pro SDK. Thanks, David
... View more
12-17-2019
07:37 AM
|
0
|
1
|
1302
|
POST
|
I'm developing an add-in that needs to programatically import a Layout from a PAGX file into a Project. The import itself is working fine, but I need to use the Layout object immediately after it is added. This becomes a problem when there are name collisions, given that Arc Pro automatically appends a number when a Layout with an existing name is added. I do have the unmodified name in memory (stored in a custom object), so when duplicate names are NOT an issue, I can "search" for the new Layout with the call Layout myNewLayout = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(item => item.Name == knownLayoutName).GetLayout(); When there is a name collision, however, this call just returns the Layout with the given name that existed pre-import (since the new Layout is now named something like "myNewLayout1"). Thus far, the only way I have found to get the correct LayoutProjectItem is to first find the latest SourceModifiedTime of all of the Project's LayoutProjectItems, and then filter on item.SourceModifiedTime == maxModifiedTime. This seems to be working, but I don't actually know why...when I step through the code with the debugger, it seems that the SourceModifiedTime attribute for every LayoutProjectItem is just some default value. Part of the issue is that the actual import has to be done with ItemFactory.Instance.Create(), which returns an IProjectItem value. That value cannot be cast to a LayoutProjectItem, and from what I gather, the LayoutProjectItem doesn't even exist until Project.Current.AddItem() is called. The originally returned IProjectItem and the corresponding LayoutProjectItem don't have the same CacheID property, either, and other than SourceModifiedTime, I don't see any other distinguishing attributes. So, once I make that call to AddItem(), is there a better way to retrieve exactly the Layout (or LayoutProjectItem) I just added? The fact that a Layout's unique identifier is its name seems to be the root of the issue here. Thanks, David
... View more
12-05-2019
08:07 AM
|
0
|
1
|
381
|
POST
|
The ArcPy documentation specifies methods for importing a PAGX file and converting a PAGX to a Layout. Is there a way to export an existing Layout as a PAGX file?
... View more
10-31-2019
07:56 AM
|
0
|
0
|
261
|
POST
|
Is it possible to create new elements using ArcPy, and to add them to a layout? All I've seen so far are methods that allow for cloning and deletion, but intuitively it seems like this should be doable. If this isn't possible through ArcPy, what would be the best way? -David
... View more
10-31-2019
07:42 AM
|
0
|
0
|
186
|
POST
|
We're writing an Add-In that will most likely need to call a Python script to perform certain actions on a .aprx Project file. I've seen at least one example for doing that - Run a geoprocessing task and python script | ArcGIS for Developers. In that example, there's a hard-coded path to the Python executable installed with ArcGIS Pro. However, I'm not sure if it's safe to assume every user will have that executable installed to the standard path specified in the ArcGIS Pro installer. Is there a better (and more sure-fire) way to call a Python script from C# code, specifically in the context of an Add-In? Some ArcGIS SDK method for getting at the actual Python session taking place in an ArcGIS Pro session? It'd be great to be able to do this more elegantly, and to get at the return values of the script without creating a pipe or additional output file, as well. I would think so, given the information given here: ArcGISProject—ArcPy | ArcGIS Desktop . Specifically, with regards to getting an ArcGISProject object: The second technique is to use the CURRENT keyword as an input parameter to the ArcGISProject function. This technique only works from within an ArcGIS Pro application because the ArcGISProject object references the project that is currently loaded into the ArcGIS Pro application. The CURRENT keyword can be used in the Python window or with geoprocessing script tools. We're not going to be in the Python window, since this is a script being run from a C# application. How would we use geoprocessing script tools to make this happen? Similarly, we'll probably want to call some C# dlls from our Python code, rather than writing everything we need in that script in Python. Best practices for this? That might be more a general C# / .NET question than an ESRI question. Thanks, David
... View more
10-30-2019
12:24 PM
|
0
|
1
|
1899
|
POST
|
Thanks! We ended up doing something similar by calling PropertySheet.Page(_pageID) from various Page view models that needed to access one another. Along with some logic to ensure certain view models were already initialized and subscribed to certain events, it's working as needed.
... View more
10-30-2019
11:45 AM
|
0
|
0
|
2921
|
POST
|
To avoid creating another complex object within our Add-In's primary Module class, we'd like to have some our Page View Models (used in our custom Options pages) access one another. Is there any kind of built-in or best practice way of doing this? Given the singleton nature of Dockpanes, it seems like this would be possible in that context (something like a call to FrameworkApplication.DockPaneManager.Find(_dockPaneID within another dock pane), where _dockPaneID is known, and we cast the result to whatever specific DockPane subclass we need. Similarly, there's the "Current" scheme used with Modules, which just returns the result of a call to FindModule(_moduleID). Is there something analogous to be done with Pages? If not, has anyone achieved something similar using a different scheme? Ultimately, we just need various options Pages to know about each other's changed properties, which represent the settings of our Add-In.
... View more
10-22-2019
06:53 AM
|
0
|
3
|
3497
|
POST
|
Thanks! I tried the second solution, and it worked. -David
... View more
09-20-2019
03:20 PM
|
0
|
0
|
704
|
POST
|
Thanks for responding, Uma. Unfortunately, I'm still stuck on this issue. This is a case of situation #2 - I am referencing an image in a resource DLL. To be more specific, the Add-In project uses a view defined in a referenced DLL, which itself refers to another resource DLL that contains the icons. Copy Local is set to true in both instances. If I go to the ArcGIS Pro App Cache, I can see both of these DLLs there (the one that defines the view and the one with the icons). This scheme works as expected in our other applications that use the same view and icon. For some reason, it's just not working with an ArcGIS Pro add-in. Any other advice?
... View more
09-20-2019
11:54 AM
|
0
|
2
|
704
|
POST
|
We're building an Add-In (C#) whose buttons open up quite a few different dialogs. Some of these dialogs are instantiated directly from a view in the Add-In project, and others are instantiated from views that exist in other referenced projects. The icons in question all exist within a different project. No matter the specific case, these icons are not showing up in the dialogs opened within the Add-In. Even so, they DO show up in the XAML editor. The only way we've been able to get icons to show up is to place them directly into an Images folder within the Add-In's project. This is fine in a couple of cases, but in general it doesn't work because we're using Dialogs that exist in our common / core set of projects. These dialogs and their respective icons work just fine in every other WPF application. Is there some way around this issue, other than pulling all of those dialogs and their respective images into our Add-In's project's code? We're using the typical Source="pack://application:,,,/Assembly;component/path" referencing scheme in the Source attribute of the Image element in the XAML of these dialogs.
... View more
09-18-2019
02:34 PM
|
0
|
5
|
807
|
POST
|
Huh, I didn't know about adding dependencies. I'm still a little unclear, though. So, in my situation (sounds like yours, as well), I would actually create two Add-Ins. One of them manages the loading of settings from Project files, and the other does all of the other business logic. The "core" / settings module will be auto-loaded as soon as Arc Pro is fired up. The other Add-In depends on the core module...but what does that achieve? Will OnReadSettingsAsync be fired again when the second module is loaded? I'm just not understanding how this scheme offers access to Project settings at times other than Project load.
... View more
09-16-2019
07:36 AM
|
0
|
1
|
549
|
POST
|
Thanks Gintautas Kmieliauskas - I'm already doing just that, though. I read in settings when the Project loads and store those in an in-memory object. But that's not what I need in a few specific situations. What I want to be able to do is access the settings stored in the Project file - not in the Add-In's in-memory object - at times other than Project load. Because of the potential timing issues with loading Projects and licensing, it might be important to access the Project file's settings at other times.
... View more
09-16-2019
07:08 AM
|
0
|
3
|
549
|
POST
|
Is it possible to call OnReadSettingsAsync() explicitly, in addition to overriding the method? There are potentially times at which I'll need to access Project-level settings other than when a Project is opened. Most notably, I might need to access Project-level settings for an Add-In that a user enables after they have already opened a Project. For instance: 1. User A, who has already licensed our custom Add-In, passes a Project file with Add-In custom settings to User B, who has not yet licensed the Add-In. 2. User B licenses the Add-In, which they had previously installed but not licensed. 3. Now that the Add-In is licensed, its settings need to be read from the Project into the Add-In's in-memory settings object. -David
... View more
09-13-2019
03:17 PM
|
0
|
5
|
620
|
Title | Kudos | Posted |
---|---|---|
1 | 01-07-2021 06:11 AM | |
1 | 07-01-2020 12:23 PM | |
1 | 12-30-2020 01:45 PM | |
2 | 10-08-2020 07:49 AM |