Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

CATSCRIPT and Digitized Shape Editor (DSE lic)

Status
Not open for further replies.

jissididi

Automotive
Mar 17, 2015
46
FR
Hi everyone,

I'm trying to write a macro for Catia V5 R22 to automate the creation of several planar sections with DSE licence.
But I Can't find the command to do this, it seems like the only thing that I can do with macro is automate the creation of elements from Generative Shape Design workbench.
Can you help me out ?

Bes regards

Jissididi
 
Replies continue below

Recommended for you

Ok Ferdo, thanks !

and have you an idea of how you do to chose the cloud of points you want to apply the planar section on using its name and the name of the plane you will use ?

I read something about it at this adress :
but as I didn´t find any list of all the commands and syntax used on catia, Im kind of blocked...

Thanks again
 
Ok so I finaly found out,

In fact, I call the Planar Section command, and then I select both of the parameters I need to make the section


Code:
Dim oSelection as Selection 
Set oSelection = CATIA.ActiveDocument.Selection
Dim namer As String
namer = Inputbox("Please enter the EXACT name of the Point Cloud you want to divide.")
oSelection.Search "Name=" & namer & "*,all" 

Dim oSelection2 as Selection 
Set oSelection2 = CATIA.ActiveDocument.Selection

Dim j As Integer
Dim k As Integer
			
			For j = 0 To 9

				CATIA.StartCommand "Planar Sections"

oSelection.Search "Name=" & namer & "*,all"

oSelection2.Search "Name=" & "plane" & j & "*,al

But now I have a new problem : I have to clic on the apply button after each selection and finaly on the ok button but I don`t now how to do it ^^

Any idea ?
 
Hey,

so I ve been looking around for this sendkeys command,

but it looks like using Catscript to code, it doesn t work... :/

do you have any other idea or I just might be writing it bad?
 
So I decided to re write the program in VBscript not using the catscript thing,

I found some examples on the internet but couldn't make them work

Code:
Language="VBSCRIPT"

Sub CATMain()


	Dim WSShell


	Set WSShell = CreateObject(“WScript.Shell”)


	Set partDocument1 = CATIA.ActiveDocument


	Set part1 = partDocument1.Part

	
	Set hybridBodies1 = part1.HybridBodies

	
	Set hybridBody1 = hybridBodies1.Add()

	hybridBody1.name = "geometrical set number 1"

	part1.InWorkObject = hybridBody1

	
	Set hybridShapeFactory1 = part1.HybridShapeFactory


	Set axisSystems1 = part1.AxisSystems

	
	Set axisSystem1 = axisSystems1.Item("Absolute Axis System")

			
			For i = 0 To 9

				
				Set reference1 = part1.CreateReferenceFromBRepName("RSur:(Face:(Brp:(AxisSystem.1;2);None:();Cf11:());WithPermanentBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", axisSystem1)

				
				Set reference2 = part1.CreateReferenceFromBRepName("REdge:(Edge:(Face:(Brp:(AxisSystem.1;3);None:();Cf11:());Face:(Brp:(AxisSystem.1;2);None:();Cf11:());None:(Limits1:();Limits2:());Cf11:());WithPermanentBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", axisSystem1)

			
				Set hybridShapePlaneAngle1 = hybridShapeFactory1.AddNewPlaneAngle(reference1, reference2, i, False)


				hybridShapePlaneAngle1.ProjectionMode = False


				hybridBody1.AppendHybridShape hybridShapePlaneAngle1


				part1.InWorkObject = hybridShapePlaneAngle1


				Set ItemToRename =hybridShapePlaneAngle1


				ItemToRename.Name ="plane" & i


			Next

	part1.Update 


Set oSelection = CATIA.ActiveDocument.Selection


namer = Inputbox("First, please make sure that you activated the DSE licence for CATIA (Tools/Option/General/Shareable Products), then, Please enter the EXACT name of the Point Cloud you want to divide.")


oSelection.Search "Name=" & namer & "*,all" 


Set oSelection2 = CATIA.ActiveDocument.Selection

			
			For j = 0 To 9


				CATIA.StartCommand "Planar Sections"


				oSelection.Search "Name=" & namer & "*,all"


				oSelection2.Search "Name=" & "plane" & j & "*,all" 


						For k = 0 to 14


								'CATIA.RefreshDisplay = True


								WSShell.SendKeys “c:FrmActivate”


								WSShell.SendKeys “{TAB}”


						Next


						For k = 0 to 15


								'CATIA.RefreshDisplay = True


								WSShell.SendKeys “c:FrmActivate”


								WSShell.SendKeys “{ENTER}”


						Next
			

			Next
 
Well I also tried this one down there, and it game me the error that it needed some object WScript...
Code:
Language="VBSCRIPT"

Sub CATMain()

Set WshShell = WScript.CreateObject("WScript.Shell")

WScript.sleep 200
WshShell.SendKeys WScript.Arguments.Unnamed(0) ' if input to enter
WshShell.SendKeys "{ENTER}"

	Set partDocument1 = CATIA.ActiveDocument
	Set part1 = partDocument1.Part	
	Set hybridBodies1 = part1.HybridBodies	
	Set hybridBody1 = hybridBodies1.Add()
	hybridBody1.name = "geometrical set number 1"
	part1.InWorkObject = hybridBody1	
	Set hybridShapeFactory1 = part1.HybridShapeFactory
	Set axisSystems1 = part1.AxisSystems	
	Set axisSystem1 = axisSystems1.Item("Absolute Axis System")
			
			For i = 0 To 9
				
				Set reference1 = part1.CreateReferenceFromBRepName("RSur:(Face:(Brp:(AxisSystem.1;2);None:();Cf11:());WithPermanentBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", axisSystem1)
				Set reference2 = part1.CreateReferenceFromBRepName("REdge:(Edge:(Face:(Brp:(AxisSystem.1;3);None:();Cf11:());Face:(Brp:(AxisSystem.1;2);None:();Cf11:());None:(Limits1:();Limits2:());Cf11:());WithPermanentBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", axisSystem1)
				Set hybridShapePlaneAngle1 = hybridShapeFactory1.AddNewPlaneAngle(reference1, reference2, i, False)
				hybridShapePlaneAngle1.ProjectionMode = False
				hybridBody1.AppendHybridShape hybridShapePlaneAngle1
				part1.InWorkObject = hybridShapePlaneAngle1
				Set ItemToRename =hybridShapePlaneAngle1
				ItemToRename.Name ="plane" & i

			Next

part1.Update 
Set oSelection = CATIA.ActiveDocument.Selection
namer = Inputbox("First, please make sure that you activated the DSE licence for CATIA (Tools/Option/General/Shareable Products), then, Please enter the EXACT name of the Point Cloud you want to divide.")
oSelection.Search "Name=" & namer & "*,all" 
Set oSelection2 = CATIA.ActiveDocument.Selection
			
			For j = 0 To 9

				CATIA.StartCommand "Planar Sections"
				oSelection.Search "Name=" & namer & "*,all"
				oSelection2.Search "Name=" & "plane" & j & "*,all" 

						For k = 0 to 14

								WshShell.SendKeys "{TAB}"

						Next

						For k = 0 to 15

								WshShell.SendKeys "{ENTER}"
						Next

			Next

	part1.Update 

End Sub
 
If you work with a vbs file (not catvbs) you need first to get CATIA

On Error Resume Next
Dim CATIA '', WScript As New Object
CATIA = GetObject("", "CATIA.Application")

Then, before or after SendKeys, depending on what you want, you need a waiting time to let CATIA to write in the power input and launch the commands. There are few threads here about this and the problems comming using this tehniques. That post on Mike Berry's blog is very useful.

Regards
Fernando

- Romania
- EU
 
So it means that I need to use :

One vbs file as one created with notepad witch will call the sendkeys inside catia ?


and One catvbs to choose the parameters ?


I wrote this, there is no more error message but it seems like the sendkeys"¨TABÇ" and ENTER doesnt work well, maybe a problem of timer as you said or is there something wrong before ?

code of vbs file whos name is CMD_APPLIER_PLANAR_SECTIONS

Code:
Set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Sleep 6000

WshShell.AppActivate "CATIA V5"
WScript.Sleep 6000

for i=0 to 11

WshShell.SendKeys "{TAB}", TRUE
WScript.Sleep 6000

Next

WshShell.SendKeys "{ENTER}", TRUE
WScript.Sleep 6000

for i=0 to 15

WshShell.SendKeys "{TAB}", TRUE
WScript.Sleep 6000

Next

WshShell.SendKeys "{ENTER}", TRUE
WScript.Sleep 6000

Code of catvbs :

Code:
Language="VBSCRIPT"

Sub CATMain()

	Set partDocument1 = CATIA.ActiveDocument
	Set part1 = partDocument1.Part	
	Set hybridBodies1 = part1.HybridBodies	
	Set hybridBody1 = hybridBodies1.Add()
	hybridBody1.name = "geometrical set number 1"
	part1.InWorkObject = hybridBody1	
	Set hybridShapeFactory1 = part1.HybridShapeFactory
	Set axisSystems1 = part1.AxisSystems	
	Set axisSystem1 = axisSystems1.Item("Absolute Axis System")

num = Inputbox("Please chose the step to divide the model")
			
			For i = 0 To (180/num-1)
				
				Set reference1 = part1.CreateReferenceFromBRepName("RSur:(Face:(Brp:(AxisSystem.1;2);None:();Cf11:());WithPermanentBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", axisSystem1)
				Set reference2 = part1.CreateReferenceFromBRepName("REdge:(Edge:(Face:(Brp:(AxisSystem.1;3);None:();Cf11:());Face:(Brp:(AxisSystem.1;2);None:();Cf11:());None:(Limits1:();Limits2:());Cf11:());WithPermanentBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", axisSystem1)
				Set hybridShapePlaneAngle1 = hybridShapeFactory1.AddNewPlaneAngle(reference1, reference2, (num*i), False)
				hybridShapePlaneAngle1.ProjectionMode = False
				hybridBody1.AppendHybridShape hybridShapePlaneAngle1
				part1.InWorkObject = hybridShapePlaneAngle1
				Set ItemToRename =hybridShapePlaneAngle1
				ItemToRename.Name ="plane" & i

			Next

part1.Update 
Set oSelection = CATIA.ActiveDocument.Selection
namer = Inputbox("First, please make sure that you activated the DSE licence for CATIA (Tools/Option/General/Shareable Products), then, Please enter the EXACT name of the Point Cloud you want to divide.")
oSelection.Search "Name=" & namer & "*,all" 
Set oSelection2 = CATIA.ActiveDocument.Selection
			
			For j = 0 To (180/num-1)

				CATIA.StartCommand "Planar Sections"
				oSelection.Search "Name=" & namer & "*,all"
				oSelection2.Search "Name=" & "plane" & j & "*,all" 

				cmd = "wscript T:\JDarsu\CMD_APPLIER_PLANAR_SECTIONS.vbs"

				

			Next

	part1.Update 

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top