Autor
|
Thema: LS-OPT and CATIA (1483 mal gelesen)
|
Sam2021 Mitglied Student
Beiträge: 30 Registriert: 26.03.2018
|
erstellt am: 26. Mrz. 2018 10:01 <-- editieren / zitieren --> Unities abgeben:
Dear everyone, Good morning. "Sincere apologies that i have made my request in English" I am trying to build a model for optimization on LS-OPT. hence i would like to use my parametric CATIA model and couple it with LS OPT using makro .CATVbs script using CNET.exe. Could someone please share some guidance as how its done? or please share some skript where i could get output as .stp file? the model is a simple side sill where parameters such as angle will be changed. I use CATIA v5. any help wll be greatly appreciated. Thank you and looking forward to hear from you. Regards, Sam Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
bgrittmann Moderator Konstrukteur
Beiträge: 11780 Registriert: 30.11.2006 CATIA V5R19
|
erstellt am: 26. Mrz. 2018 11:13 <-- editieren / zitieren --> Unities abgeben: Nur für Sam2021
|
Sam2021 Mitglied Student
Beiträge: 30 Registriert: 26.03.2018
|
erstellt am: 26. Mrz. 2018 11:42 <-- editieren / zitieren --> Unities abgeben:
Dear Bernd, Thank you very much for the feedback. 1. CATIA release: v5-6 relaease 2014, Build day: 01-12-2014.20.00 2. In this attached CAT file, i would like to change the parameters as listed, "Amplitude, angle, Radius, wavelength" I will fix the upper and lower bound for those parameters in the LS-OPT GUI. So everytime the parameter gets changed, the LS OPT will request the CNET.exe ( if i am correct) to realise the changes in the model using .CATVBS script and give output as .stp file to Hypermesh. ==> It would be really helpful if a sample script with which i could realise this. Thank you Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
bgrittmann Moderator Konstrukteur
Beiträge: 11780 Registriert: 30.11.2006 CATIA V5R19
|
erstellt am: 26. Mrz. 2018 11:57 <-- editieren / zitieren --> Unities abgeben: Nur für Sam2021
Hi Have you tried to record the manual change of these parameters with the macro recorder? You could use this recorded code to develop your specialized code. Regards, Bernd ------------------ Warum einfach, wenn es auch kompliziert geht. Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
Sam2021 Mitglied Student
Beiträge: 30 Registriert: 26.03.2018
|
erstellt am: 26. Mrz. 2018 12:46 <-- editieren / zitieren --> Unities abgeben:
Dear Bernd, Honestly i havent. Since i am using this option for the first time, there are some difficulties for me in achieving that. I thought i would generate a script where the parameters can be changed using string variable. Do you think manually changing and recording is more efficient? Or can i just redit the script you had provided in your fist reply? Thank you Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
Sam2021 Mitglied Student
Beiträge: 30 Registriert: 26.03.2018
|
erstellt am: 26. Mrz. 2018 12:49 <-- editieren / zitieren --> Unities abgeben:
If you see the model, under feature tree ==> arameters, i would want the LS OPT tool to vary the last four parameters. SO, the combination could be more than i could do manually. Hence i thought i would use the script where it does the job automatically. Best regards, Sam Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
bgrittmann Moderator Konstrukteur
Beiträge: 11780 Registriert: 30.11.2006 CATIA V5R19
|
erstellt am: 26. Mrz. 2018 12:59 <-- editieren / zitieren --> Unities abgeben: Nur für Sam2021
Hi Yes, the record would be the first step. The analyze the code, understand it and the modify if. (see also here how you get the parameters) How do you wanna change the values for the parameters in the macro? Regards, Bernd PS: Because I using an older release I could't open your files. Could you post a screen shot where are the parameters located? ------------------ Warum einfach, wenn es auch kompliziert geht. Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
Sam2021 Mitglied Student
Beiträge: 30 Registriert: 26.03.2018
|
erstellt am: 26. Mrz. 2018 13:08 <-- editieren / zitieren --> Unities abgeben:
1. I will record a macro and see how it works. 2. I would give the range in the LS OPt. Everytime it asks, lets say change the angle to some value, it would change in the script and generate the new geom. file (If i understood your question correctly) 3. You mean the paramaters in the future tree? if yes, please see the attached file. Thank you Best regards, Sam [Diese Nachricht wurde von Sam2021 am 26. Mrz. 2018 editiert.] Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
bgrittmann Moderator Konstrukteur
Beiträge: 11780 Registriert: 30.11.2006 CATIA V5R19
|
erstellt am: 26. Mrz. 2018 13:25 <-- editieren / zitieren --> Unities abgeben: Nur für Sam2021
Hi A code example for two of these parameters: Code:
Sub CATMain()Dim partDocument1 As Document Set partDocument1 = CATIA.ActiveDocument Dim part1 As Part Set part1 = partDocument1.Part Dim parameters1 As Parameters Set parameters1 = part1.Parameters Dim TotalLenghtPara As Parameter Set TotalLenghtPara = parameters1.RootParameterSet.DirectParameters.Item("Total_Lenght") TotalLenghtPara.Value = 300 Dim AnglePara As Parameter Set AnglePara = parameters1.RootParameterSet.DirectParameters.Item("Angle") AnglePara.Value = -10 End Sub
Regards, Bernd ------------------ Warum einfach, wenn es auch kompliziert geht. Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
Sam2021 Mitglied Student
Beiträge: 30 Registriert: 26.03.2018
|
erstellt am: 26. Mrz. 2018 13:28 <-- editieren / zitieren --> Unities abgeben:
|
Sam2021 Mitglied Student
Beiträge: 30 Registriert: 26.03.2018
|
erstellt am: 26. Mrz. 2018 13:49 <-- editieren / zitieren --> Unities abgeben:
Hello, 1. Please ignore the previous email. it was sent before noticing your latest reply. 2. Now I have used your example script and built one for my problem. I kindly request you to take a look when you have time. thank you Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
bgrittmann Moderator Konstrukteur
Beiträge: 11780 Registriert: 30.11.2006 CATIA V5R19
|
erstellt am: 26. Mrz. 2018 13:55 <-- editieren / zitieren --> Unities abgeben: Nur für Sam2021
Hi Please try to understand the code and not only copy code snippets in one file. My code was written as .CATScript. (maybe you should also use CASTScript) Also have a look on the documentation (V5Automation.chm in the Catia install folder). Regards, Bernd ------------------ Warum einfach, wenn es auch kompliziert geht. Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
Sam2021 Mitglied Student
Beiträge: 30 Registriert: 26.03.2018
|
erstellt am: 26. Mrz. 2018 14:36 <-- editieren / zitieren --> Unities abgeben:
|
Sam2021 Mitglied Student
Beiträge: 30 Registriert: 26.03.2018
|
erstellt am: 26. Mrz. 2018 18:54 <-- editieren / zitieren --> Unities abgeben:
Dear Bernd, I read the manual and have created a script. I couldnt fix the syntax error which occurs while i try to run. COuld you please take a look into the script file when you have time and help me trouble shoot the issue? thank you Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
bgrittmann Moderator Konstrukteur
Beiträge: 11780 Registriert: 30.11.2006 CATIA V5R19
|
erstellt am: 26. Mrz. 2018 21:44 <-- editieren / zitieren --> Unities abgeben: Nur für Sam2021
Hi Here is a corrected Scipt (save as .CATScript) Code: Sub CATMain()Dim FileToOpen as String Dim partDocument1 As Document Dim part1 As Part Dim AnglePara As Parameter Dim parameters1 As Parameters Dim AmplitudePara As Parameter Dim WavelengthPara As Parameter Dim FilletradiusPara As Parameter FileToOpen = "E:\Datei\Results\Optimization\CAD_parametric_modelling_schweller\CAD_wichtiges\Schweller_fully_corrugated.CATPart" Set partDocument1 = CATIA.Documents.Open(FileToOpen) Set part1 = partDocument1.Part Set parameters1 = part1.Parameters Set AnglePara = parameters1.RootParameterSet.DirectParameters.Item("Angle") AnglePara.Value = -10 Set AmplitudePara = parameters1.RootParameterSet.DirectParameters.Item("Amplitude") AmplitudePara.Value = 20 Set WavelengthPara = parameters1.RootParameterSet.DirectParameters.Item("Wavelength") WavelengthPara.Value = 30 Set FilletradiusPara = parameters1.RootParameterSet.DirectParameters.Item("Fillet_Radius") FilletradiusPara.Value = 2 partDocument1.ExportData "c:\temp\myFileName.stp", "stp" End Sub
I havn't tested the code. Regards, Bernd ------------------ Warum einfach, wenn es auch kompliziert geht. Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
Sam2021 Mitglied Student
Beiträge: 30 Registriert: 26.03.2018
|
erstellt am: 27. Mrz. 2018 08:15 <-- editieren / zitieren --> Unities abgeben:
|
bgrittmann Moderator Konstrukteur
Beiträge: 11780 Registriert: 30.11.2006 CATIA V5R19
|
erstellt am: 27. Mrz. 2018 16:44 <-- editieren / zitieren --> Unities abgeben: Nur für Sam2021
|
Sam2021 Mitglied Student
Beiträge: 30 Registriert: 26.03.2018
|
erstellt am: 27. Mrz. 2018 18:51 <-- editieren / zitieren --> Unities abgeben:
|
Sam2021 Mitglied Student
Beiträge: 30 Registriert: 26.03.2018
|
erstellt am: 28. Mrz. 2018 08:15 <-- editieren / zitieren --> Unities abgeben:
|
Sam2021 Mitglied Student
Beiträge: 30 Registriert: 26.03.2018
|
erstellt am: 29. Mrz. 2018 14:40 <-- editieren / zitieren --> Unities abgeben:
Dear Bernd, I ran the script using command line. The script run fine but it asks for my approval to overwrite the existing stp file. Is it possible to include a syntax where it knows it can overwrite the existing .stp file every time there was a change in the macro? thankyou Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
bgrittmann Moderator Konstrukteur
Beiträge: 11780 Registriert: 30.11.2006 CATIA V5R19
|
erstellt am: 29. Mrz. 2018 14:49 <-- editieren / zitieren --> Unities abgeben: Nur für Sam2021
|
Sam2021 Mitglied Student
Beiträge: 30 Registriert: 26.03.2018
|
erstellt am: 29. Mrz. 2018 15:37 <-- editieren / zitieren --> Unities abgeben:
Dear Bernd, It works perfectly fine. Thank you. Just one more doubt. If i want to use python to execute the script, is it possioble? i looked up online and there was some sugeestions. I tried but i get this error. So i checked this error, they say the python version was 64. i checked it is 32. yet the error reappears. COuld you please help me fix this if its possible? Thank you best regards, Sam Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
Sam2021 Mitglied Student
Beiträge: 30 Registriert: 26.03.2018
|
erstellt am: 31. Mrz. 2018 14:44 <-- editieren / zitieren --> Unities abgeben:
Dear Bernd, About the .CATscript, it only works when i go to command line "CNEXT.exe directory" -macro"scriptdirectory". so if i double click the macros script file while CATIA interface is closed, the CATIA userinterface opens up and just blank (i.e. it wont run the model"). Should i include any command to the macro script wherein it says run it in batchmode? Thank you very much and looking forward to hear from you. Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
bgrittmann Moderator Konstrukteur
Beiträge: 11780 Registriert: 30.11.2006 CATIA V5R19
|
erstellt am: 31. Mrz. 2018 15:05 <-- editieren / zitieren --> Unities abgeben: Nur für Sam2021
Hi Have you tried the additional parameter -batch (also described in the previous posted link)? Have you specified the environment? (-direnv, -env) According to your other opened thread: IMHO would be the best option to using only your Python script to handle the tasks in Catia (using COM-Interface). But I have no idea how that works in Python. Regards, Bernd ------------------ Warum einfach, wenn es auch kompliziert geht. Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
Sam2021 Mitglied Student
Beiträge: 30 Registriert: 26.03.2018
|
erstellt am: 31. Mrz. 2018 15:41 <-- editieren / zitieren --> Unities abgeben:
Dear Bernd, 1. actually i tried the very example where -batch, -env were used. it didnt work. so then i used the command line as "directory where cnext is located" -macro "directory where script is located". it worked totally fine. then i tried to start the CATIA interface by using the maccro directly. but it didnt work. From command line ==> using -batch, -env, -macro'==> didnt work. just with -macro works From directly the script file by double clicling it, it doesnt work. CATIA opens but the model is not being launched. Thank you very much.
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
bgrittmann Moderator Konstrukteur
Beiträge: 11780 Registriert: 30.11.2006 CATIA V5R19
|
erstellt am: 31. Mrz. 2018 15:53 <-- editieren / zitieren --> Unities abgeben: Nur für Sam2021
Hi, Please post the complete command lines you tried an the results. Maybe the is a mistake in them. Have you used the correct parameters for environment an so one? Bernd PS: Please use unique file names for the attachments, otherwise the files will be overwritten and other user cannot follow the discussion (also in the future)
------------------ Warum einfach, wenn es auch kompliziert geht. Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
Sam2021 Mitglied Student
Beiträge: 30 Registriert: 26.03.2018
|
erstellt am: 31. Mrz. 2018 16:21 <-- editieren / zitieren --> Unities abgeben:
Dear Bernd, 1. Command line ["C:\FK-Programme\Dassault Systemes\B24\win_b64\code\bin\CNEXT.exe" -batch -macro "E:\Datei\Results\Optimization\LS_OPT_results\Optimization_model_1\Macro_schweller_model_lsopt.CATScript"[ ==> result ==< a new stp file was created and saved in the directory but the CATIA interface was not opened (everything happened in the background". 2. ["C:\FK-Programme\Dassault Systemes\B24\win_b64\code\bin\CNEXT.exe" -env CATIA.V5-R2014.B24 -batch -macro "E:\Datei\Results\Optimization\LS_OPT_results\Optimization_model_1\Macro_schweller_model_lsopt.CATScript"[ ==> result ==< a new stp file was created and saved in the directory but the CATIA interface was not opened (everything happened in the background". I sincerely apoogise. both times it worked. i didnt know because i was expecting the catia interface to open. In both cases, it didnt but newly updated .stp file was saved. Now i used this following script. Sub CATMain() Dim FileToOpen as String Dim partDocument1 As Document Dim part1 As Part Dim AnglePara As Parameter Dim parameters1 As Parameters Dim AmplitudePara As Parameter Dim WavelengthPara As Parameter FileToOpen = "E:\Datei\Results\Optimization\LS_OPT_results\Optimization_model_1\Schweller_fully_corrugated.CATPart" Set partDocument1 = CATIA.Documents.Open(FileToOpen) Set part1 = partDocument1.Part Set parameters1 = part1.Parameters Set AnglePara = parameters1.RootParameterSet.DirectParameters.Item("Angle") AnglePara.Value = -7 Set AmplitudePara = parameters1.RootParameterSet.DirectParameters.Item("Amplitude") AmplitudePara.Value = 20 Set WavelengthPara = parameters1.RootParameterSet.DirectParameters.Item("Wavelength") WavelengthPara.Value = 50 CATIA.DisplayFileAlerts = False partDocument1.Part.Update partDocument1.ExportData "E:\Datei\Results\Optimization\LS_OPT_results\Optimization_model_1\Schweller.stp", "stp" End Sub
When i double clicked the script, i had expected it to open the interface and run the script and save the model but it wont. just the catia window opened and nothing happens. Or my expectation for this particular script is wrong? Thank you very much
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
Sam2021 Mitglied Student
Beiträge: 30 Registriert: 26.03.2018
|
erstellt am: 31. Mrz. 2018 19:47 <-- editieren / zitieren --> Unities abgeben:
Dear Bernd, Am i supposed to include anything such as "execute" in the beginning of .CATScript file in order for the CATIA application to start automatically when the .CATSCript is executed? Thank you very much. Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |