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!

CATIA V6 Plane repitition 1

Status
Not open for further replies.

Lars26B

Aerospace
Aug 5, 2015
8
NL
Hi!

I'm looking for a script or macro which allows me to create planes on all points and a curve i have made.

I have a excel file with xyz coordinates which I import into Catia (V6 GSD) creating a geometrical set called "GeometryFromExcel". This geometrical set contains all points and creates a spline through all these points.

I want to create planes on every single point regardless of its name (example: Point.1 or point.50 shouldnt matter). Using the "normal to curve" function of planes.

The amount of points may vary.
Hope you guys can help out!

Cheers
 
Replies continue below

Recommended for you

do you import excel points into V6 with a script?

Eric N.
indocti discant et ament meminisse periti
 
I Do. I use the script which is already in Catia. I believe its called : GSD_PointSplineLoftfromExcel.xls
 
why don't you modify it to create the plane?

Eric N.
indocti discant et ament meminisse periti
 
So basically i want to have a set of planes all offset from the XY plane which can be made using a txt file or excel file.

I've tried to record my own macro but i do not know how to get it to loop...
As written above, I do have a way to input points and a line using a excel table.. just not the planes yet.


Code:
Sub CATMain()

Dim editor1 As Editor
Set editor1 = CATIA.ActiveEditor

Dim part1 As Part
Set part1 = editor1.ActiveObject

Dim hybridShapeFactory1 As HybridShapeFactory
Set hybridShapeFactory1 = part1.HybridShapeFactory

Dim hybridBodies1 As HybridBodies
Set hybridBodies1 = part1.HybridBodies

Dim hybridBody1 As HybridBody
Set hybridBody1 = hybridBodies1.Item("GeometryFromExcel")

Dim hybridShapes1 As HybridShapes
Set hybridShapes1 = hybridBody1.HybridShapes

Dim hybridShapeSpline1 As HybridShapeSpline
Set hybridShapeSpline1 = hybridShapes1.Item("Spline.1")

Dim reference1 As Reference
Set reference1 = part1.CreateReferenceFromObject(hybridShapeSpline1)

Dim hybridShapePointCoord1 As HybridShapePointCoord
Set hybridShapePointCoord1 = hybridShapes1.Item("Point.1")

Dim reference2 As Reference
Set reference2 = part1.CreateReferenceFromObject(hybridShapePointCoord1)

Dim hybridShapePlaneNormal1 As HybridShapePlaneNormal
Set hybridShapePlaneNormal1 = hybridShapeFactory1.AddNewPlaneNormal(reference1, reference2)

hybridBody1.AppendHybridShape hybridShapePlaneNormal1

part1.InWorkObject = hybridShapePlaneNormal1

part1.Update

Dim settingControllers1 As SettingControllers
Set settingControllers1 = CATIA.SettingControllers

Dim settingRepository1 As SettingRepository
Set settingRepository1 = settingControllers1.Item("VPMEditorDisplay")

boolean1 = settingRepository1.GetAttr("Mask_LockEditability")

End Sub
 
the loop should be around

hybridShapes1.Item("Point.1")


you can loop all element in hybridShapes1 and test if you have a point

Code:
for each oShape in hybridShapes1

 if typename(oShape) = "Point" then

Set hybridShapePointCoord1 = oShape

[...]


next

that should take all points in that geometrical set



Eric N.
indocti discant et ament meminisse periti
 
I now have below code. It doesnt give an error but doesnt do anything either. I'm sorry for being such a newbie at scripting..

Code:
Sub CATMain()

Dim editor1 As Editor
Set editor1 = CATIA.ActiveEditor

Dim part1 As Part
Set part1 = editor1.ActiveObject

Dim hybridShapeFactory1 As HybridShapeFactory
Set hybridShapeFactory1 = part1.HybridShapeFactory

Dim hybridBodies1 As HybridBodies
Set hybridBodies1 = part1.HybridBodies

Dim hybridBody1 As HybridBody
Set hybridBody1 = hybridBodies1.Item("GeometryFromExcel")

Dim hybridShapes1 As HybridShapes
Set hybridShapes1 = hybridBody1.HybridShapes

Dim hybridShapeSpline1 As HybridShapeSpline
Set hybridShapeSpline1 = hybridShapes1.Item("Spline.1")

Dim reference1 As Reference
Set reference1 = part1.CreateReferenceFromObject(hybridShapeSpline1)

Dim hybridShapePointCoord1 As HybridShapePointCoord

[b]For Each oShape In hybridShapes1

If TypeName(oShape) = "Point" Then

Set hybridShapePointCoord1 = oShape
[/b]
Dim reference2 As Reference
Set reference2 = part1.CreateReferenceFromObject(hybridShapePointCoord1)

Dim hybridShapePlaneNormal1 As HybridShapePlaneNormal
Set hybridShapePlaneNormal1 = hybridShapeFactory1.AddNewPlaneNormal(reference1, reference2)

hybridBody1.AppendHybridShape hybridShapePlaneNormal1

part1.InWorkObject = hybridShapePlaneNormal1

part1.Update

Dim settingControllers1 As SettingControllers
Set settingControllers1 = CATIA.SettingControllers

Dim settingRepository1 As SettingRepository
Set settingRepository1 = settingControllers1.Item("VPMEditorDisplay")

boolean1 = settingRepository1.GetAttr("Mask_LockEditability")

[b]End If
Next[/b]
End Sub
 

insert

Code:
MsgBox (TypeName(oShape))

before

Code:
If TypeName(oShape) = "Point" Then

this will help you find the type of point

once you have it replace

Code:
If TypeName(oShape) = "[u]Point[/u]" Then

with the proper Type.

do this with a small number of points in your file.

Eric N.
indocti discant et ament meminisse periti
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top