×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

to create polyline in catia using VB

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
 

RE: to create polyline in catia using VB

(OP)
Hi,

Can anybody expert entertain my question? I really stuck. ponder

Thanks.

RE: to create polyline in catia using VB

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

RE: to create polyline in catia using VB

(OP)
Hi.

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

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

RE: to create polyline in catia using VB

BTW I am really helping you by telling you to get the book!

Eric N.
indocti discant et ament meminisse periti

RE: to create polyline in catia using VB

(OP)
Eric,

Thanks for your suggestion. I just get the book and will start exploring the book. smile

Thanks

RE: to create polyline in catia using VB

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources