Continue to Site

Welcome to MCAD Central

Join our MCAD Central community forums, the largest resource for MCAD (Mechanical Computer-Aided Design) professionals, including files, forums, jobs, articles, calendar, and more.

Vb api: how to modify points coordinates?

p.vergneault

New member
Hi,

I'm using vba to work on points in a .prt file.
Up to now I can have access to their names and id, but I can't modify their coordinates.

Anyone with an idea on the subject?

Thanks
 
Up to now I can read their coordinates, I can also modify their names. I found what seems to be a command to modify coordinates, but vba does not accept the syntax that is given by the user's guide.

Here is an example which should give a name to points, set their coordinates then display it in an excel spreadsheet. Everything is working well, except the 3 lines with the ".set(X, Y)" command.
I must have missed something...thanks for your answer anyway

Sub test()

Dim asynconn As New pfcls.CCpfcAsyncConnection
Dim conn As pfcls.IpfcAsyncConnection
Dim session As pfcls.IpfcBaseSession
Dim i As Integer
Dim model As IpfcModelItemOwner
Dim points As IpfcModelItems
Dim lepoint As IpfcPoint
Dim pointPosition As IpfcPoint3D
Dim PtName As String

Set conn = asynconn.Connect("", "", ".", 5)
Set session = conn.session
Set model = session.CurrentModel()
Set points = model.ListItems(EpfcModelItemType.EpfcITEM_POINT)
Set piece = model

For i = 0 To points.Count - 1
PtName = points(i).GetName
Cells(i + 1, 1) = PtName
Set lepoint = points.Item(i)
Set pointPosition = lepoint.point
points.Item(i).SetName ("toto_" & i)
pointPosition.Set(0, Xvalue)
pointPosition.Set(1, Yvalue)
pointPosition.Set(2, Zvalue)

Next i

For i = 0 To points.Count - 1
PtName = points(i).GetName
Cells(i + 1, 1) = PtName
Set lepoint = points.Item(i)
Set pointPosition = lepoint.point
Cells(i + 1, 2) = pointPosition.Item(0)
Cells(i + 1, 3) = pointPosition.Item(1)
Cells(i + 1, 4) = pointPosition.Item(2)
Next i

conn.Disconnect (2)

End
 
Hi, p.vergneault

Newbie here. I know a bit about vba and would like to work on the same.

I tried your above code but still unable to get the connection itself.
It'll be great if you can elaborate on the same how you are able to achieve the connection.

Thanks in advance
Maddy
 
Hi Maddy,

This is the only way I know to connect VBA to ProE.
Do you have any error message from ProE?
It can only work if you use wildfire4 or a more recent version. Did you read vbug.pdf? There are a few things to set up on your computer before using the VB API.
 

Sponsor

Articles From 3DCAD World

Back
Top