to create polyline in catia using VB
to create polyline in catia using VB
(OP)
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).
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?
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
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).
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?
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





RE: to create polyline in catia using VB
Can anybody expert entertain my question? I really stuck.
Thanks.
RE: to create polyline in catia using VB
make a loop - for/next around:
Set hybridShapePointCoord2 = hybridShapes1.Item("Point.X")
Set reference2 = part1.CreateReferenceFromObject(hybridShapePointCoord2)
hybridShapePolyline1.InsertElement reference2, .X
indocti discant et ament meminisse periti
RE: to create polyline in catia using VB
Eric already told you what to do, in the attachment is something very basic...I don't know if this will help you.
Regards
Fernando
RE: to create polyline in catia using VB
Eric and Fernando,
Thanks for your kind reply.
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
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.
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
RE: to create polyline in catia using VB
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)
indocti discant et ament meminisse periti
RE: to create polyline in catia using VB
indocti discant et ament meminisse periti
RE: to create polyline in catia using VB
Thanks for your suggestion. I just get the book and will start exploring the book.
Thanks
RE: to create polyline in catia using VB
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
indocti discant et ament meminisse periti