cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

How to update geometry(part) using VBA

SM_9791973
9-Granite

How to update geometry(part) using VBA

Hi,

I have certain questions pl. help me in finding solutions

1) How to know whether the installed creo is installed with VB API ( means it supports VB files)

2) I want to create or the modify the part dimensions through VBA (excel) to easily modify the part without doing it manually ( means opening the part and editing the dimensions) will it be possible? if yes if anybody has small example(program or the part running through VBA) it would be great for understanding

3) I want replace the part in assembly using VBA will it be possible to do?

 

Any positive response are welcomed

 

Regards,

Shubham

5 REPLIES 5
HanSolo97
5-Regular Member
(To:SM_9791973)

Hi,

1) In your system, navigate to "C:\Program Files\PTC\Creo_4\M060\Common Files\vbapi". (For Creo 4)
If this folder is available then VB API is installed in your system.

2) The only way to change geometry/model dimensions using VB API is using parameters. Using relations you can map dimensions to parameters. 
Use this article as reference to build the automation. you can find the code to change parameter values using VBA API.
https://www.academia.edu/14405592/Methods_to_Automate_CREO_Design_through_VB_API (credits to the author)

Thanks,
Hanson

Thank you HanSolo97 for the reply,

If possible could you share that document with me here in the attachment format as its too costly for me to buy.

 

I have one question using VBA is it possible to active or supress any part in the assembly as per the need of the design means i will be having one master model & in that i will be having all the components of having different combinations , if i need certain components then will it be possible to update the dimensions and active or suppress the parts using VBA?

 

Regards,

Shubham Mehta   

HanSolo97
5-Regular Member
(To:SM_9791973)

Hi,
The answers you are looking for is already available in the community 

To Change model parameters:
https://community.ptc.com/t5/Customization/vb-api-parameters/td-p/143766

 

To Suppress/un-suppress features using Feat ID:
https://community.ptc.com/t5/Customization/Hiding-Suppressing-parts-using-Creo-VB-API/td-p/292002

 

Hi Hansolo97,

Thank you so much for sharing the links!

That was the only one thing which i was trying to finding out....

 

Regards,

Shubham Mehta

RPN
14-Alexandrite
14-Alexandrite
(To:HanSolo97)

Hi, this is not the only way.

 

CCpfcProgramExportInstructions/CCpfcProgramImportInstructions Are available,  now you can  replace in the text file the dim you want to modify.

Find the dim in the program file, and replace the line ,d38 = 5.0’ by ‚MODIFY d38 = 12.5‘

For me that’s more simple as to create the relations upfront.

 

And as I understand the documentation, you are able to change a dim with VB

 

Dimension Objects
Dimension objects include standard Creo Parametric dimensions as well as reference dimensions. Dimension objects enable you to access dimension tolerances and enable you to set the value for the dimension. Reference dimensions allow neither of these actions.
Getting Dimensions
Dimensions and reference dimensions are Creo Parametric model items. See the section Getting ModelItem Objects for methods that can return IDimension and IRefDimension objects.
Dimension Information
Methods Introduced:
IpfcBaseParameter.Value IpfcBaseDimension.DimValue IpfcBaseParameter.IsDesignated IpfcBaseParameter.IsModified IpfcBaseParameter.ResetFromBackup() IpfcBaseParameter.IsRelationDriven IpfcBaseDimension.DimType IpfcBaseDimension.Symbol IpfcBaseDimension.Texts
All the IBaseParameter methods are accessible to Dimensions as well as Parameters. 

Good Luck

Announcements