Results 1 to 5 of 5
-
02-05-2015, 02:00 PM #1
- Join Date
- May 2005
- Posts
- 14
Export model to STEP (CREO VBA API)
Hello,
So I am pulling my hairs out at the minute as I am incapable of getting my export command to work. I have copied and pasted methods from wherever I can find them... Thing is, nothing works, and there really isnt much information out there. Anyway, I have pasted a bit of my script below... basically, there is a syntax error, or an unset variable... God only knows...
The documentation says I have to call the 'Is x supported' things before making the export command, so I try do that... not sure I have that bit right either. Im taking pot shots in the dark here...
Is there a CREO VBA API mastermind out there who could lend me a hand? This is one of the final hurdles I am facing (there are a couple of other ones too... but hey, baby steps), and If I can get this to work, I would happily buy whoever works it out a beer!
Dim ICS As Boolean
Dim IGRS As Boolean
Dim GeoFlag As IpfcGeometryFlags
Dim Step3D As IpfcSTEP3DExportInstructions
Dim Export3D As IpfcExport3DInstructions
Dim Export As IpfcExportInstructions
Set GeoFlag = New CCpfcGeometryFlags
ICS = session.IsConfigurationSupported(EpfcExportType.Ep fcEXPORT_STEP, EpfcAssemblyConfiguration.EpfcEXPORT_ASM_FLAT_FILE )
IGRS = session.IsGeometryRepSupported(EpfcExportType.Epfc EXPORT_STEP, GeoFlag)
GeoFlag.AsSolids = True
Set Step3D = New CCpfcSTEP3DExportInstructions
Set Export3D = Step3D
Set Export = Export3D
Model1.Export ("D:\AJBS\Script_Test\JBA_TEST.stp", export)
-
02-05-2015, 02:00 PM
-
02-16-2015, 03:54 PM #2
- Join Date
- May 2005
- Posts
- 14
So I'm cleaning up my code, and understanding the things that work in VBA vs VB... Can be tricky... but basically i am still falling at the last hurdle.
Here is my updated code, which as far as i can see, is almost there...
but I cannot get the design.export("test.prt", xxxx) part of the code to finish... I get a compile error, or a missing = or any other result...
It's a right PITA... Doesn't anyone have a nugget of wisdom to impart...?
Dim Design As IpfcModel
Dim DDes As IpfcModelDescriptor
Dim cDDes As CCpfcModelDescriptor
Dim DesEx As IpfcExportInstructions
Dim Des3DEx As IpfcExport3DInstructions
Dim DesExStep As IpfcSTEP3DExportInstructions
Dim cDesExStep As CCpfcSTEP3DExportInstructions
Dim DesFlags As IpfcGeometryFlags
Dim cDesFlags As CCpfcGeometryFlags
Dim DesG As Boolean
Dim DesC As Boolean
Set cDDes = New CCpfcModelDescriptor
Set DDes = cDDes.Create(EpfcModelType.EpfcMDL_PART, "Design", "JBA_TEST")
session.OpenFile(DDes).Activate
Dim DesSolid As pfcls.IpfcSolid
If session.CurrentModel.Type = EpfcModelType.EpfcMDL_PART Then
Set DesSolid = session.CurrentModel
DesSolid.Regenerate (zero)
End If
Set Design = session.CurrentModel
Set cDesFlags = New CCpfcGeometryFlags
Set DesFlags = cDesFlags.Create
DesC = pfc.session.IsConfigurationSupported(EpfcExportTyp e.EpfcEXPORT_STEP, EpfcAssemblyConfiguration.EpfcEXPORT_ASM_SINGLE_FI LE)
DesG = pfc.session.IsGeometryRepSupported(EpfcExportType. EpfcEXPORT_STEP, DesFlags)
DesFlags.AsSolids = True
Set cDesExStep = New CCpfcSTEP3DExportInstructions
Set DesExStep = cDesExStep.Create(EpfcModelType.EpfcMDL_PART, DesFlags)
Set Des3DEx = DesExStep
Set DesEx = Des3DEx
-----What goes here?-----------
and then once this works it's beer o'clock...
-
02-16-2015, 03:54 PM
-
02-17-2015, 01:57 PM #3
- Join Date
- May 2005
- Posts
- 14
Somehow this worked.... (so if you're struggling with it too, maybe it'll help... It is now officially beer o'clock).
Sub Button3_Click()
'-----------------------------------------------------------------------------------------------------
'------------------------------------ Connect to CREO-----------------------------------------------
'-----------------------------------------------------------------------------------------------------
Dim asyncConnection As IpfcAsyncConnection
Dim cAC As CCpfcAsyncConnection
Dim session As IpfcBaseSession
Set cAC = New CCpfcAsyncConnection
Set asyncConnection = cAC.Connect(dbnull, dbnull, dbnull, dbnull)
Set session = asyncConnection.session
'-----------------------------------------------------------------------------------------------------
'------------------------------------ Set Working Directory --------------------------------------
'-----------------------------------------------------------------------------------------------------
Dim Workdir As String
Workdir = ActiveWorkbook.FullName
position = InStrRev(Workdir, "\")
Workdir = Left(Workdir, position)
session.ChangeDirectory (Workdir)
'MsgBox ("Working Directory = " & Workdir)
'-----------------------------------------------------------------------------------------------------
'------------------------------------ Load Project Master --------------------------------------
'-----------------------------------------------------------------------------------------------------
'Dim MaDes As IpfcModelDescriptor
'Dim cMaDes As CCpfcModelDescriptor
'Dim MaModel As IpfcModel
'Set cMaDes = New CCpfcModelDescriptor
'Set MaDes = cMaDes.Create(EpfcModelType.EpfcMDL_PART, "JBA_TEST", "JBA_TEST")
'session.OpenFile(MaDes).Activate
Set MaModel = session.GetActiveModel
'MaModel.Copy ("Master.PRT")
'-----------------------------------------------------------------------------------------------------
'----------------------------------- Break to Design ------------------------------------------
'-----------------------------------------------------------------------------------------------------
Dim Design As IpfcModel
Dim DDes As IpfcModelDescriptor
Dim cDDes As CCpfcModelDescriptor
Dim DesEx As IpfcExportInstructions
Dim Des3DEx As IpfcExport3DInstructions
Dim DesExStep As IpfcSTEP3DExportInstructions
Dim cDesExStep As CCpfcSTEP3DExportInstructions
Dim DesFlags As IpfcGeometryFlags
Dim cDesFlags As CCpfcGeometryFlags
Dim DesG As Boolean
Dim DesC As Boolean
Set cDDes = New CCpfcModelDescriptor
Set DDes = cDDes.Create(EpfcModelType.EpfcMDL_ASSEMBLY, "HJBA", "HJBA")
session.OpenFile(DDes).Activate
Dim DesSolid As pfcls.IpfcSolid
If session.CurrentModel.Type = EpfcModelType.EpfcMDL_ASSEMBLY Then
Set DesSolid = session.CurrentModel
DesSolid.Regenerate (UpdateInstances)
DesSolid.Regenerate (zero)
End If
Set Design = session.CurrentModel
Set cDesFlags = New CCpfcGeometryFlags
Set DesFlags = cDesFlags.Create
DesFlags.AsSolids = True
DesC = session.IsConfigurationSupported(EpfcExportType.Ep fcEXPORT_STEP, EpfcAssemblyConfiguration.EpfcEXPORT_ASM_MULTI_FIL ES)
MsgBox ("DesC = " & DesC)
DesG = session.IsGeometryRepSupported(EpfcExportType.Epfc EXPORT_STEP, DesFlags)
MsgBox ("DesG = " & DesG)
Set cDesExStep = New CCpfcSTEP3DExportInstructions
Set DesExStep = cDesExStep.Create(EpfcAssemblyConfiguration.EpfcEX PORT_ASM_MULTI_FILES, DesFlags)
Set Des3DEx = DesExStep
Set DesEx = Des3DEx
If session.CurrentModel.Type = EpfcModelType.EpfcMDL_ASSEMBLY Then
Set Design = session.CurrentModel
Design.export "d:\AJBS\Script_Test\Test.STP", DesEx
End If
-
02-17-2015, 01:57 PM
-
03-03-2016, 09:25 AM #4
- Join Date
- Sep 2015
- Posts
- 5
Hello,
thx, the step export works!
I also want to export STL, but i dont get it running:
step3DIGES = (New CCpfcTriangulationInstructions).Create(0.5, 0.5) fails when i export it
and when i want to check the configuration i get a fail: not supported
tc = Session.IsConfigurationSupported(EpfcExportType.Ep fcEXPORT_STL_BINARY, EpfcAssemblyConfiguration.EpfcEXPORT_ASM_FLAT_FILE )
Has anybody a working export for STL?
It would help a lot!
-
05-18-2019, 02:46 PM #5
- Join Date
- Dec 2008
- Posts
- 9
I want to save the current display as .jpg or .png.
any idea of how to do it?Tiago Figueiredo
Can you use WT parts (gear parts) to create a BOM on a drawing. And can it be parametric? Part of our company uses eboms that is no BOM on the drawing just in windchill. The rest of use use a table...
using wtparts to create BOM on...