Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

to create polyline in catia using VB

Status
Not open for further replies.

nizammuaidi

Automotive
Dec 2, 2008
12
0
0
MY
Hi there,

I have search around this forum to create the polyline in CATIA using VB. What I found was reversed process (create the point from polyline).

[blue]My question is, how can I set the VB code to be repeated to create the polyline until the end of the point that I have created?[/blue]

Below is the macro that I have reorded from CATIA.

Set hybridShapePolyline1 = hybridShapeFactory1.AddNewPolyline()
Set hybridBodies1 = part1.HybridBodies
Set hybridBody1 = hybridBodies1.Item("Geometrical Set.1")
Set hybridShapes1 = hybridBody1.HybridShapes
Set hybridShapePointCoord1 = hybridShapes1.Item("Point.1")
Set reference1 = part1.CreateReferenceFromObject(hybridShapePointCoord1)
hybridShapePolyline1.InsertElement reference1, 1

Set hybridShapePointCoord2 = hybridShapes1.Item("Point.2")
Set reference2 = part1.CreateReferenceFromObject(hybridShapePointCoord2)
hybridShapePolyline1.InsertElement reference2, 2

hybridShapePolyline1.Closure = False
Set hybridBody2 = hybridBodies1.Item("Geometrical Set.2")
hybridBody2.AppendHybridShape hybridShapePolyline1
part1.InWorkObject = hybridShapePolyline1
part1.Update
 
Replies continue below

Recommended for you

where is the problem?

make a loop - for/next around:

Set hybridShapePointCoord2 = hybridShapes1.Item("Point.X")
Set reference2 = part1.CreateReferenceFromObject(hybridShapePointCoord2)
hybridShapePolyline1.InsertElement reference2, .X

Eric N.
indocti discant et ament meminisse periti
 
Hi.

Eric and Fernando,

[blue]Thanks for your kind reply.[/blue]

For loop statement, I am able to call the points from excel data as below:

'retrive data from excel
sp = 32
For i = 1 To npoints
x = Excel.Cells(i + sp, 4).Value
y = Excel.Cells(i + sp, 5).Value
z = Excel.Cells(i + sp, 6).Value

[green]However I don't have any idea how to call points from catia tree (as per attachment). I have tried to do looping on the polyline syntax as Eric suggest but it didn't works.[/green]

To be frank, this is my first time doing programming and I don't have any programming experience before.

Hope you guys can help me as a beginner.

Thanks


 
 http://files.engineering.com/getfile.aspx?folder=96d55e3f-60dc-4e8a-8ee9-cb097b04446d&file=catia_points.jpg
why don't you get a VB/VBA book ?

VBA for dummies is very good. You will learn much more and faster from the book than from the forum (at least when you start learning)

Eric N.
indocti discant et ament meminisse periti
 
very good!

let us kow if you find a solution.. if not i will make sure you find a solution.

At the begining I used the object explorer very often.... be curious and look at the content of a sketch

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