Skip to main content
5-Regular Member
April 15, 2023
Solved

Create DRW Table with VBA and VB API

  • April 15, 2023
  • 1 reply
  • 1598 views

Hello,

 

I want to create a table in a Creo 4.0 Paramteric drawing with (Excel) VBA and use the VB API.

When I use the CCpfcTableCreateInstructions.Create() I expected to get back an object of type IpfcTableCreateInstructions (like in the PTC user Guide).

But I get a object of type IDpfcTableCreateInstructions.

 

So after many hours of try and error I am desperated.

 

This is my code:

 

Dim TableLocation As CpfcPoint3D
Dim TableCreationInstructionsFactory As CCpfcTableCreateInstructions
Dim TableCreateInstructions As IpfcTableCreateInstructions

 

Set TableLocation = New CpfcPoint3D
TableLocation.Set 0, 0#
TableLocation.Set 1, 0#
TableLocation.Set 2, 0#

 

Set TableCreationInstructionsFactory = New CCpfcTableCreateInstructions

Set TableCreationInstructions = TableCreationInstructionsFactory.Create(TableLocation)

 

When I use the CCpfcTableCreateInstructions.Create() Method I get a variant of type IDpfcTableCreateInstructions back. 

 

I use Creo 4.0 M150.

 

Thanks a lot for support!

 

 

Best answer by YaroslavSin

Try this code snippet

Dim tableInstructions As IpfcTableCreateInstructions
Dim location As CpfcPoint3D

'======================================================================
'Set table position
'======================================================================
location = New CpfcPoint3D
location.Set(0, 500.0)
location.Set(1, 500.0)
location.Set(2, 0.0)

'======================================================================
'Setup the table creation instructions
'======================================================================
tableInstructions = (New CCpfcTableCreateInstructions).Create(location)

 

1 reply

17-Peridot
April 18, 2023

Try this code snippet

Dim tableInstructions As IpfcTableCreateInstructions
Dim location As CpfcPoint3D

'======================================================================
'Set table position
'======================================================================
location = New CpfcPoint3D
location.Set(0, 500.0)
location.Set(1, 500.0)
location.Set(2, 0.0)

'======================================================================
'Setup the table creation instructions
'======================================================================
tableInstructions = (New CCpfcTableCreateInstructions).Create(location)