Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

Vb api: how to modify points coordinates?

  • Thread starter Thread starter p.vergneault
  • Start date Start date
P

p.vergneault

Guest
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
 
if the point is not build in this .prt and its not a feature ,i think it can't be changed
 
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.
 

Part and Inventory Search

Sponsor

Back
Top