DataStandard/ACADM 2021, set Vault User to Author

m_hermann
Collaborator
Collaborator

DataStandard/ACADM 2021, set Vault User to Author

m_hermann
Collaborator
Collaborator

Hello,

first of all

'I wish all of you a happy new year with health and luck'

 

I have problems setting the vault user to ACAD Author. 

This is my DataStandard Code in CAD- default.ps1:

 

$author = $VaultConnection.username
$Prop["Author"].Value = $author

 

That works fine for Inventor but not AUTOCAD.

 

Many thx for help

 

0 Likes
Reply
Accepted solutions (1)
486 Views
8 Replies
Replies (8)

Markus.Koechl
Autodesk
Autodesk

Hi Michael,

I suggest using the AdminService instead: the code below is part of the VDS 2021 Quickstart sample configuration.

			#set the active user as Designer for file property mapping or mechanical title attribute mapping
			$mUserId = $vault.AdminService.SecurityHeader.UserId
			$mUser = $vault.AdminService.GetAllUsers() | Where-Object { $_.id -eq $mUserId}
			if($Prop["GEN-TITLE-NAME"].Value)
			{
				$Prop["GEN-TITLE-NAME"].Value = $mUser.Name
			}

 Note - Vault 2022 improved accessing the user information. The code next applies for VDS 2022: 

			#set the active user as Designer for file property mapping or mechanical title attribute mapping
			$mUser = $vault.AdminService.Session.User
			if($Prop["GEN-TITLE-NAME"].Value) #if($Prop["Designer"].Value)
			{
				$Prop["GEN-TITLE-NAME"].Value = $mUser.Name #	$Prop["Designer"].Value = $mUser.Name
			}


Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes

m_hermann
Collaborator
Collaborator

Hi Karkus,

many thanks.

This is my code in 'OnPostClose' function

"AutoCADWindow"
		{
			mWriteLastUsedFolder
			
             #set the active user as Designer for file property mapping or mechanical title attribute mapping
			$mUserId = $vault.AdminService.SecurityHeader.UserId
			$mUser = $vault.AdminService.GetAllUsers() | Where-Object { $_.id -eq $mUserId}
			if($Prop["DESIGNED_FROM"].Value)
			{
				$Prop["DESIGNED_FROM"].Value = $mUser.Name
			}  
            		$Prop["000_IDENT"].Value = $Prop["DocNumber"].Value
					$Prop["005_Erstellungsdatum"].Value = $Prop["DESIGNED_AT"].Value = (Get-Date -format dd.MM.yyyy)
		}
		default

 

But it doesn't work. 

Is this the wrong code- position?

Do i have to specify the titel block name?

I don't find the code in Quickstart 2021 sample. Could you send me the link please?

0 Likes

Markus.Koechl
Autodesk
Autodesk
I would rather move it to the InitializeWindow function to get the field pre-filled, but this should not enable/disable the approach from working properly.
The title block name registration is relevant only if you expect an instant visual update of attribute-based title blocks. To funnel the issue I would set a break statement and check, that the file property "DESIGNED FROM" is filled first.
The link to my snippet's context is: https://github.com/koechlm/VDS-Sample-Configuration-2022/blob/main/VDS-2022-PDMC-Sample/CAD.Custom/a..., line 315.


Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes

m_hermann
Collaborator
Collaborator

Hi Markus,

 

this is my code with which it only works. The code in # does not work

$mUserId = $vault.AdminService.SecurityHeader.UserId
                    $mUser = $vault.AdminService.GetAllUsers() | Where-Object { $_.id -eq $mUserId}
                    $Prop["DESIGNED_FROM"].Value = $mUser.Name
                        # if($Prop["DESIGNED_FROM"].Value)
                        # {
                            # #$Prop["DESIGNED_FROM"].Value = $mUser.Name
                        # } 

But i had to delete the AutoCAD attribute from the current title_block and had to place a new attribute with the same conditions and same name. Does anyone understand autocad 🤔

 

Now it works as expected, but only if an Vault administrator is logged in. What do i have to do that this works with all 'normal' users?

 

error.png

0 Likes

Markus.Koechl
Autodesk
Autodesk

Is the property "DESIGNED_FROM" a mapped file attribute or just a block attribute (with block attribute mapping in Vault)?

The 303 error is indicating that your Vault misses the Admin User Read permission for all users in the Vault configuration. Since we introduced the custom role configuration in Vault 2019, we always recommend creating a custom role consuming "Admin User Read" permission to support API extensions that access user/group information.



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes

m_hermann
Collaborator
Collaborator

It works now with new custom role for 'Administrator API Read'.

But i have to test it with customer environment.

 

DESIGNED_FROM is a Vault- mapped AutoCAD attribute.

Here are my screenshots.

 

These are the file Properties bevor using Data Standard

 

Title_Block.png

 

here we found the attribute 'DESIGNED_FROM'

 

Title_Block-attribute.png

 

This is what i had in 2018

 

this is what i had in 2018 with Data Standard.png

 

This is the code from 2018

 

default.ps1 - 2018.png

 

OnPostClose

 

OnPostClose- deafault.ps1- 2018.png

 

Vault Mapping

 

 

Vault- Mapping.png

 

That worked best for creating new files in autocad and with Copy Design in Vault for the last 3 years with no problems with 30 users and replicated Vault Environment.

Now in 2021 the code for the 'Author' doesn't work anymore and this is the reason why i make a detour via  'DESIGNED-FROM' directly with your code.  

 

0 Likes

Markus.Koechl
Autodesk
Autodesk
Accepted solution

Hi Michael,

I investigated the latest 2022 and 2021 environments. Working with the default configuration, the $Prop["Author"] handled returns the expected results.

"AutoCADWindow" {
			#rules applying for AutoCAD
			if ($Prop["Author"]) {
				$Prop["Author"].Value = $vaultConnection.UserName
			}

I need to correct my previous post in regards to retrieving the user name: The logged-in user does not require "Admin User Read" permission to read the own name. However, reading groups or other users' info requires it.

VDS 2021 and 2022 populate the $vaultConnection.UserName. 

Another aspect to consider is that the UDP Author needs to be mapped and linked to the drawing category. One criteria missing will cause VDS not to save the value (what makes sense...).

Please validate the findings first. If the customized configuration continues to fail, I suggest checking the VDS log file for other issues.



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes

m_hermann
Collaborator
Collaborator

Hi Markus,

with your new code snippet it works as expected for AutoCAD.

All my functionality which worked in 2018 are now working for 2021

 

Many thanks

0 Likes