I am unable to update a drawing parameter in creo with vba. Suggestions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I am unable to update a drawing parameter in creo with vba. Suggestions?
I am unable to update a drawing parameter in creo with excel vba. I can retrieve and change a 'BaseParameter.TextValue' according to vba, but the parameter doesn't change on the drawing or in the parameters window. Have also tried updating/saving with no luck. Any suggestions?
This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.
Solved! Go to Solution.
- Labels:
-
General
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Adam, here is my VB.NET code for writing to a model param (i dont have any code for writing to a drawing param, but i guess it should be quite similar)
PDUtils refers to a set of functions (PDUtils.vb) that i copied from the vbparam example included in the Creo installation.
' Get type
Dim type As String = PDUtils.getTypeFromParam(CType(param, IpfcBaseParameter).Value)
' Create value
paramValue = PDUtils.createParamValue(param_value, type)
' Set value
CType(param, IpfcBaseParameter).Value = paramValue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Adam, here is my VB.NET code for writing to a model param (i dont have any code for writing to a drawing param, but i guess it should be quite similar)
PDUtils refers to a set of functions (PDUtils.vb) that i copied from the vbparam example included in the Creo installation.
' Get type
Dim type As String = PDUtils.getTypeFromParam(CType(param, IpfcBaseParameter).Value)
' Create value
paramValue = PDUtils.createParamValue(param_value, type)
' Set value
CType(param, IpfcBaseParameter).Value = paramValue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hugo, Thank you for your suggestion.
have you ran into an instance where you were trying to update the value of an existing parameter? The parameter I am trying to update is text so I think I can pass it directly as a string. So far the variable updates and the Creo data does not, visibly anyway. I will review the vb.net code for PDUtils, I had it up yesterday.
In Solidworks I was never able to get variables (the Creo version of parameters) to update either; I had to delete and recreate them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Here is how I update parameters using Excel:
Sub AddValuez()
'TITLE1 is the name of the parameter I am updating
Application.ScreenUpdating = False
Dim asynconn As New pfcls.CCpfcAsyncConnection
Dim conn As pfcls.IpfcAsyncConnection
Dim session As pfcls.IpfcBaseSession
Dim model1 As IpfcModel
Dim mdlname
Dim paramOwn As IpfcParameterOwner
Dim Moditem As New CMpfcModelItem
Dim ipTITLE1 As IpfcParameter
Dim ipbTITLE1 As IpfcBaseParameter
Dim pnTITLE1 As String
Dim TITLE1nv As IpfcParamValue
pnTITLE1 = "TITLE1"
'Connect
Set conn = asynconn.Connect("", "", ".", 5)
Set session = conn.session
Set model1 = session.CurrentModel
Set solid = model1
Set paramOwn = model1
Set Powner = model1
Set ipTITLE1 = paramOwn.GetParam(pnTITLE1)
Set ipbTITLE1 = ipTITLE1
'Sheets("Parameters").Range("B48").Value is where the value is housed.
Set TITLE1nv = Moditem.CreateStringParamValue(Sheets("Parameters").Range("B48").Value)
ipbTITLE1.Value = TITLE1nv
End Sub