×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

insert the custom properties txt file?

insert the custom properties txt file?

insert the custom properties txt file?

(OP)
Vb script

hello
macro or vb script, import and insert the custom properties in part, starting from a txt file.???

RE: insert the custom properties txt file?

Hi,

You mean user defined properties ? How is looking your text file ?

Check also CATIA Portable Script Center, if I remember correctly, it is an example there (or few?).

Regards
Fernando

https://picasaweb.google.com/102257836106335725208

RE: insert the custom properties txt file?

(OP)
Hi,

Ferdo

insert in catpart user custom properties, with a txt file.

exemplo

menu-editar-product-define othrer properties - external properties
load the txt file, myproperties.txt.

This file has properties defined for other catparts
I have a macro to insert the properties,
insert txt file loads the properties filled


is possible with one catscript or catvba??
I do not know how to start.

thank you

RE: insert the custom properties txt file?

Hi,

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.

Regards
Fernando

https://picasaweb.google.com/102257836106335725208

RE: insert the custom properties txt file?

(OP)
hello

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

I can help,

thank you

RE: insert the custom properties txt file?

Hi,

Look at the code bellow, is a CATScript

Sub CATMain()

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 = fso.OpenTextFile("C:\temp\User_Parameter.txt", ForReading)
Do While MyFile.AtEndOfLine=false
ReadLineTextFile = MyFile.ReadLine

'''here you need write your code
Loop




Regards
Fernando

https://picasaweb.google.com/102257836106335725208

RE: insert the custom properties txt file?

(OP)
Hi,

Ferdo,

I'm learning, Vbscript
write the code, post here when ready

thank you,

RE: insert the custom properties txt file?

(OP)
hi

ferdo,

look at the code,

Sub CATMain ()

Set partDocument1 = CATIA.ActiveDocument
Set product1 = partDocument1.GetItem ("")

Set oCATIAFileSys = CATIA.FileSystem
Set oFile = oCATIAFileSys.GetFile (sDocPath & "C: \ Users \ Eddy and Sarah \ Documents \ Projects \ VBScript \ 123.txt")
Set oTextSteam oFile.OpenAsTextStream = ("ForReading")

Oline = oTextSteam.ReadLine
Set parameters1 = product1.UserRefProperties
Set strparam1 parameters1.CreateString = ("", "")
strparam1.Value = oline
strparam1.Rename "Edcarlos01"

Oline = oTextSteam.ReadLine
Set parameters2 = product1.UserRefProperties
Set strparam2 parameters2.CreateString = ("", "")
strparam2.Value = oline
strparam2.Rename "Edcarlos02"

end Sub

what do you think? can get better,
have to set the txt file. create and rename the parameters in macro
the property value import txt file

RE: insert the custom properties txt file?

Hello,

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)

Thank you

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources