Yes, is possible. You have to read in your macro line by line your txt file, set user parameters and values to them and write in User Defined Properties.
The only problem is your txt file to have always the same format, so you can read it correct in your macro. In that chm file you have an example how to write to a txt file, you can adapt to how to read from a txt, then put all together with your macro to insert properties.
If you still have problems, post your code here so we could help you.
Sub CATMain()
Set partDocument1 = CATIA.ActiveDocument
Set product1 = partDocument1.GetItem("")
Set parameters1 = product1.UserRefProperties
Set strParam1 = parameters1.CreateString("teste01", "")
strParam1.ValuateFromString "testando1"
Set product1 = product1.ReferenceProduct
End Sub
I use this to enter a new property, then ok
txt file to insert not know
I do not know vb program. about macro in Catia
Dim partDocument1 As PartDocument
Dim part1 As Part
Dim parameters1 As Parameters
Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
Set parameters1 = part1.Parameters
Set product1 = partDocument1.GetItem(part1.Name)
Set parameters2 = product1.UserRefProperties
'~ ’Create Userproperties
Set strParam1 = parameters2.CreateString("MyUserProperty", "Hello Guys")
part1.update
End Sub
This was an example how user defined properties can be created (only one parameter). As far as I know, when importing a txt file, you will have same result like creating few user defined properties.
So, the idea is to read the text file line by line in macro, get from there the user properties and the values one by one from each line ( for example MyUserProperty2 and "Hello Guys 2" a.s.o.), then write them in strParam2 , strParam3.....
To read from a text file you can do it somehow like (pseudo code):
'~ ' ---------------------------------------
Const ForReading = 1, ForWriting = 2
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fspenTextFile("C:\temp\User_Parameter.txt", ForReading)
Do While MyFile.AtEndOfLine=false
ReadLineTextFile = MyFile.ReadLine
I am ok to create userrefproperties, but how could you remove a userrefproperties that is already created in the doc ?? For example, i have a part with a userrefproperties called "TEST" and i want to remove it via a macro (in order to make a recursive loop on all a produxt)