[CatiaV5 R18] Interface to fill part names
[CatiaV5 R18] Interface to fill part names
(OP)
Hello,
First, i want to thx you for your help in the previous post. I creat a new subject.
I want to creat an interface to fill "part names". So i'll try to explain you in the following lines how my macro script should work.
After launching Catia V5, I should click on macro and launch it, the macro should like the following panel, where i'll find an interface that i had to fill the blanks. After filling the blanks, Catia will openend me a part, with the text written in the blanks.The written stuff will be replace the proprietes of the part
To understand it, i show it in a drawing.
I know who to built a userpannel in Visual Basic but i didn't know how to code it.
If you can help me !
I will be grateful
Here is the code of 4 parts

First, i want to thx you for your help in the previous post. I creat a new subject.
I want to creat an interface to fill "part names". So i'll try to explain you in the following lines how my macro script should work.
After launching Catia V5, I should click on macro and launch it, the macro should like the following panel, where i'll find an interface that i had to fill the blanks. After filling the blanks, Catia will openend me a part, with the text written in the blanks.The written stuff will be replace the proprietes of the part
To understand it, i show it in a drawing.
I know who to built a userpannel in Visual Basic but i didn't know how to code it.
If you can help me !
I will be grateful
Here is the code of 4 parts
CODE -->
Language="VBSCRIPT"
Sub CATMain()
Dim documents1 As Documents
Set documents1 = CATIA.Documents
Dim partDocument1 As Document
Set partDocument1 = documents1.Add("Part")
Dim part1 As Part
Set part1 = partDocument1.Part
Dim bodies1 As Bodies
Set bodies1 = part1.Bodies
Dim body1 As Body
Set body1 = bodies1.Add()
part1.Update
Dim body2 As Body
Set body2 = bodies1.Add()
part1.Update
Dim body3 As Body
Set body3 = bodies1.Add()
part1.Update
End Sub 





RE: [CatiaV5 R18] Interface to fill part names
My advice is to check the net (see FAQ) to see how others are dealing with forms in vba, eventually look for manuals for programming in vba, is quite the same in CATIA.
Look also in online docs, there are also some examples there. Then try to post your code, a simple record macro is not enough, you cannot learn in this way.
I'm also learning each day something, believe me, is a never ending process.
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
RE: [CatiaV5 R18] Interface to fill part names
Thx you, i'll try to learn the programmation in VBA, but programmaing on VBA and on CAT VBA is the same thing ?
I'll try to post my code soon !
THX
RE: [CatiaV5 R18] Interface to fill part names
Yes, they are quite similar, check some examples on net and v5automation.chm file in CATIA folder installation.
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
RE: [CatiaV5 R18] Interface to fill part names
I have just a last question, how can i attribute a field (for exemple IPN-PO) a function.
And Did you think that the eaiest way to do small programm is to make "macros" ?
Thx
RE: [CatiaV5 R18] Interface to fill part names
"A small programm" for CATIA can be done in different ways, combining different programming languages or methods or working with a single one.
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
RE: [CatiaV5 R18] Interface to fill part names
CODE --> VBA
Sub CATMain() Dim documents1 As Documents Set documents1 = CATIA.Documents Dim partDocument1 As Document Set partDocument1 = documents1.Add("Part") Dim part1 As Part Set part1 = partDocument1.Part Dim bodies1 As Bodies Set bodies1 = part1.Bodies For i = 1 To 3 bodies1.Add Next i part1.Update End SubAs for programming example I will strongly suggest VBA pour les nuls, this will give you plenty to learn even if it is Excel oriented.
Do not go in this adventure without a bit of knowledge unless your job is it to have it done by someone else.
PS it is a nice adventure and VBA is not complex... you can do it, we will help you.
indocti discant et ament meminisse periti
RE: [CatiaV5 R18] Interface to fill part names
i'm late, but i'd like to thanks you for your help.
Actually, VBA isn't my job, and i begin this adventure without any knowlege and i try different "code" founded on internet. But i think i really need to learn it properly
RE: [CatiaV5 R18] Interface to fill part names
Thx
RE: [CatiaV5 R18] Interface to fill part names
here is the code (in CATScript, not catvba, you have to adapt)
Language="VBSCRIPT"
Sub CATMain()
Dim partDocument1 As Document
Set partDocument1 = CATIA.ActiveDocument
Dim part1 As Document
Set part1 = partDocument1.Part
Dim bodies1 As Bodies
Set bodies1 = part1.Bodies
Set body1 = bodies1.Add()
Set body2 = bodies1.Add()
Set body3 = bodies1.Add()
Dim selection1 As Selection
Set selection1 = partDocument1.Selection
selection1.Search "CATPrtSearch.BodyFeature,all"
Set oDoc =CATIA.ActiveDocument ' Get current document
Set oPart = oDoc.Part ' Get the part
Set oPartBody = oPart.MainBody ' Grab the mainbody
oPartBody.Name = "Corps principal" ' Rename PartBody
body1.Name = "IPN-PO-XXXX-XX" ' Rename body1
body2.Name = "NIN-ø-XXXX"
body3.Name = "FICTATION"
body3.Name = "GURAGE"
part1.Update
End Sub
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
RE: [CatiaV5 R18] Interface to fill part names
i have already my code, here it'is
CODE --> VBA
Sub CATMain() Dim giverPartName As String givenPartName = InputBox("Type a valid part number", "Part Number Definition") If givenPartName <> "" Then Dim partDocument1 As PartDocument Set partDocument1 = CATIA.ActiveDocument Dim part1 As Part Set part1 = partDocument1.Part Dim bodies1 As Bodies Set bodies1 = part1.Bodies Dim body1 As Body Set body1 = bodies1.Add() part1.Update Dim body2 As Body Set body2 = bodies1.Add() part1.Update Dim body3 As Body Set body3 = bodies1.Add() part1.Update Set oDoc = CATIA.ActiveDocument ' Get current document Set oPart = oDoc.Part ' Get the part Set oPartBody = oPart.MainBody ' Grab the mainbody oPartBody.Name = "IPN-PO-XXXX-XX" ' Rename Body Set oDoc = CATIA.ActiveDocument ' Get current document Set oPart = oDoc.Part ' Get the part Set oPartBody = oPart.MainBody ' Grab the mainbody oPartBody.Name = "NIN-ø-XXXX" ' Rename Body Set oDoc = CATIA.ActiveDocument ' Get current document Set oPart = oDoc.Part ' Get the part Set oPartBody = oPart.MainBody ' Grab the mainbody oPartBody.Name = "FICTATION ' Rename Body" Set oDoc = CATIA.ActiveDocument ' Get current document Set oPart = oDoc.Part ' Get the part Set oPartBody = oPart.MainBody ' Grab the mainbody oPartBody.Name = "GURAGE" ' Rename Body strPath = "H:\Zeeshan MOHAMMAD\VBA\Project\ProjetVBA1.catvba" strModule = "modMain" strProcedure = "CATMain" UserForm1.Show 0 MsgBox ("Remplir les Champs") If UserForm1.TextBox1.Text = "" And _ UserForm1.TextBox2.Text = "" And _ UserForm1.TextBox3.Text = "" And _ UserForm1.TextBox4.Text = "" Then Else End If End SubAND i want to fill bodies name by this interface, i just want to know who can i put what i wrote in the "userbox" to the "bodies proprietes names"
i'm very glad to see that usually you helped me sir !
RE: [CatiaV5 R18] Interface to fill part names
See attachment, this is a catvba done very quickly and without being exactly what you want (no checks, no nice interface, no complete renames for what you want, no variables convention for names respected - in other words, if you want a nice program, don't do it like me, I've done just some copy-paste exactly how I've done also the CATScript), just to give you an idea of how many things you have to learn. Try to look here , Mark done a nice example how to use an interface in catvba.
Now you can see the differences and see why your code is not working.
Regards
Fernando
https://picasaweb.google.com/102257836106335725208