Module Aliases and Primalsense

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
jasonv
Posts: 34
Joined: Tue Jul 19, 2016 8:28 am

Module Aliases and Primalsense

Post by jasonv » Thu Sep 26, 2019 7:58 am

To help you better we need some information from you.

*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product, version and build: 5.6.167
32 or 64 bit version of product: 64
Operating system: Windows 10 Professional (1809)
32 or 64 bit OS: 64

*** Please add details and screenshots as needed below. ***

I created aliases to module functions and Primalsense does not seem to pick them up.

Within the module ...

Code: Select all

Set-Alias -Name 'List-Object' -Value 'Show-Object' -Option AllScope -Force
Export-ModuleMember -Function * -Alias * -Variable *
It's picking up the new and renamed functions but not the exported aliases.
2019-09-26 10_51_57-SAPIEN PowerShell Studio 2019.png
2019-09-26 10_51_57-SAPIEN PowerShell Studio 2019.png (13.91 KiB) Viewed 738 times
The function Show-Object exists within the module.

Both of these lines should be valid. The list-object should be red to indicate an alias.

This is after a cache rebuild, module selection and cache reload.

Note: There are several aliases defined the same way that display as expected.

Thanks.

- Jason



DO NOT POST SUBSCRIPTIONS, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM

User avatar
brittneyr
Site Admin
Posts: 187
Joined: Thu Jun 01, 2017 7:20 am

Re: Module Aliases and Primalsense

Post by brittneyr » Thu Sep 26, 2019 9:43 am

Are the alias you added appearing in the Object Browser panel?
SPS_ObjectBrowserAlias.png
SPS_ObjectBrowserAlias.png (35.3 KiB) Viewed 733 times
Brittney Ryn
SAPIEN Technologies, Inc.

User avatar
jasonv
Posts: 34
Joined: Tue Jul 19, 2016 8:28 am

Re: Module Aliases and Primalsense

Post by jasonv » Thu Sep 26, 2019 11:07 am

I changed the Set-Alias (didn't work) to New-Alias and loaded the module in PS console.

Code: Select all

New-Alias -Name 'List-Object' -Value 'Show-Object' -Force
As you can see from the "get-command -module" output the alias list-object exists.
CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Alias           List-Object                                        2.0.0.1    TMCModule
It does not show up in the object browser within in the module.

It does work within the script.

Thanks. -Jason

User avatar
jasonv
Posts: 34
Joined: Tue Jul 19, 2016 8:28 am

Re: Module Aliases and Primalsense

Post by jasonv » Thu Sep 26, 2019 12:17 pm

I got it to work. I needed to totally remove the modules from the cache and rebuild the cache. Just reloading the modules did not work. Additionally I tried to switch back to the older module, but that didn't work either. The new functions should have turned grey when I performed a cache reload.

Thanks.

User avatar
jasonv
Posts: 34
Joined: Tue Jul 19, 2016 8:28 am

Re: Module Aliases and Primalsense

Post by jasonv » Mon Sep 30, 2019 9:33 am

Additional information ...

I have my module in the PSModulePath. I'm using folder versioning within the path like the OS. By default the latest version of the module is selected. If I want to use the previous version within Sapien PS, I cannot by just selecting it and using "Build Cache" within the Cash Editor. I would think that the functions that do not exist within the old module would be unrecognized by PrimalSense. I can use the different module versions within script by using the argument RequiredVersion with the import-module command. What I'm looking for are repeatable instructions on how to switch between different versions of a module and have PrimalSense recognize the changes. It's appears I can go forward with versions, but not in reverse using older module versions.

Thanks.

- Jason

User avatar
brittneyr
Site Admin
Posts: 187
Joined: Thu Jun 01, 2017 7:20 am

Re: Module Aliases and Primalsense

Post by brittneyr » Mon Sep 30, 2019 9:41 am

If you build the cache from the cache editor, you will need to reload the cache from the ribbon.

The steps should be:
1. Change the version of the module in the Cache Editor.
2. Build Cache, then close the Cache Editor.
3. Reload the cache from the ribbon.
SPS_Reload-Cache.png
SPS_Reload-Cache.png (29.3 KiB) Viewed 620 times
Brittney Ryn
SAPIEN Technologies, Inc.

User avatar
jasonv
Posts: 34
Joined: Tue Jul 19, 2016 8:28 am

Re: Module Aliases and Primalsense

Post by jasonv » Tue Oct 01, 2019 11:01 am

That didn't work for reverting back to a previous module version. I think the issue has something to do with PS auto loading modules. If I'm in the console the steps are ...

1. Turn auto loading off

$ENV:PSModuleAutoloadingPreference = "none"

2. Remove the loaded module.

Remove-Module -Name <modulename> -Force

3. Load the module you need to work with.

Import-Module -Name <modulename> -RequiredVersion <version> -Force

I think Sapien PS somehow needs to emulate this.

Thanks.

User avatar
brittneyr
Site Admin
Posts: 187
Joined: Thu Jun 01, 2017 7:20 am

Re: Module Aliases and Primalsense

Post by brittneyr » Fri Oct 04, 2019 8:31 am

Are you still unable to get the correct PrimalSense for your previous module version?
The answer I provided has to do with updating the cache to properly color your module.

As for what modules will load into scripts, the module version that is loaded when importing a module is determined by PowerShell and the environment variable PSModulePath if you don't specify a version. This is not determined by PowerShell Studio.
Brittney Ryn
SAPIEN Technologies, Inc.

User avatar
jasonv
Posts: 34
Joined: Tue Jul 19, 2016 8:28 am

Re: Module Aliases and Primalsense

Post by jasonv » Tue Oct 08, 2019 7:20 am

To be clear, the issue I'm having is mainly adding a function to a module and having that function recognized by PrimalScript. So far I found that removing the module from the cache and then rebuilding the cache gets this working consistently.

After reviewing this article...

http://info.sapien.com/index.php/how-to ... yaW5nIl0=

At the very bottom it states. "Just remember, when having multiple versions of the same module, make sure to use the latest one."

Maybe you're enforcing that. The video depicts using an updated module.

My scripts are working as expected using the PSModulePath and have versioned folders under that path. I just use the -RequiredVersion argument if I want to used a former version of the module, otherwise PS always defaults to the latest version as expected.

Thanks.