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

Coping Parameter values from Part to Drawing

ptlw1778
1-Newbie

Coping Parameter values from Part to Drawing

Hello,

Does anyone out there know of a way or a Toolkit function that can read a Part or Assembly parameter while in a Drawing parameter. I have code that reads that reads a parameter from within the drawing that I can then copy to another parameter, I just have not been able to figure out how to access a the part parameters while in the drawing.

Thank you,

Tom

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.
3 REPLIES 3

Tom,

You need to get the part handle for the part on the drawing. With that,
you'll be able to access the part/assembly parameters.

Bob

--
Robert A. Monat
Jerand Technical Services, Inc.
http://www.jerand.com
Phone: 317-875-6087 FAX: 317-875-6612 Tollfree(US)888-4JERAND


tom.willis@oregonchain.com wrote:

>Hello,
>
>Does anyone out there know of a way or a Toolkit function that can read a Part or Assembly parameter while in a Drawing parameter. I have code that reads that reads a parameter from within the drawing that I can then copy to another parameter, I just have not been able to figure out how to access a the part parameters while in the drawing.
>
>Thank you,
>
>Tom
>
>---
>
>You are currently subscribed to toolkits.
>To unsubscribe send a blank e-mail to -.
>
>For assistance, email us at - or find other contacts at www.ptcuser.org/org/contacts.html.
>
>PTC/USER and the PTC/USER logo are registered trademarks of PTC/USER, Inc.
>Pro/ENGINEER is a registered trademark of PTC.
>
>Message authors are solely responsible for the content of their posts.
>
>
>

Tom,

Here is how I get to Part parameters from a drawing...

ProMdlCurrentGet (&drawing);
ProDrawingSolidsCollect (drawing, &solids);

/* If there is only 1 solid associated with the drawing */
model = solids[0];
/* if more than 1 solid, then you need to determine which one you want
to use */

ProMdlToModelitem(model, &modelitem);

ProStringToWstring(tmp1, "Title"); /* A parameter called "Title" */
ProParameterInit(&modelitem, tmp1, ¶m);
ProParameterValueGet(¶m, &part_title);
ProWstringToString(title, part_title.value.s_val);


ProStringToWstring(tmp2, "Rev"); /* A parameter called "Rev" */
ProParameterInit(&modelitem, tmp2, ¶m);
ProParameterValueGet(¶m, &part_rev);
ProParamvalueTypeGet(&part_rev, ¶m_type);

if (param_type == PRO_PARAM_STRING)
{
ProWstringToString(*rev, part_rev.value.s_val);
}
else if (param_type == PRO_PARAM_INTEGER)
{
fprintf("ERROR: Rev param is an integer!\n");
return(PRO_TK_GENERAL_ERROR);
}


John




tom.willis@oregonchain.com wrote:

>Hello,
>
>Does anyone out there know of a way or a Toolkit function that can read
a Part or Assembly parameter while in a Drawing parameter. I have code
that reads that reads a parameter from within the drawing that I can
then copy to another parameter, I just have not been able to figure out
how to access a the part parameters while in the drawing.
>
>Thank you,
>
>Tom
>
>---
>
>You are currently subscribed to toolkits.
>To unsubscribe send a blank e-mail to
-.
>
>For assistance, email us at - or find other
contacts at www.ptcuser.org/org/contacts.html.
>
>PTC/USER and the PTC/USER logo are registered trademarks of PTC/USER,
Inc.
>Pro/ENGINEER is a registered trademark of PTC.
>
>Message authors are solely responsible for the content of their posts.
>
>
>




---

You are currently subscribed to toolkits.
To unsubscribe send a blank e-mail to
-.

For assistance, email us at - or find other
contacts at www.ptcuser.org/org/contacts.html.

PTC/USER and the PTC/USER logo are registered trademarks of PTC/USER,
Inc.
Pro/ENGINEER is a registered trademark of PTC.

Message authors are solely responsible for the content of their posts.

Hi,
Here's another piece of code for that purpose, used to copy/create
parameters from model to drawing.


// Use the current drawing.
status = ProMdlCurrentGet ((ProMdl*)&drawing);
if (status != PRO_TK_NO_ERROR)
return (status);

// Get the drawings current/active model.
status = ProDrawingCurrentsolidGet ((ProMdl)drawing, &solid);
if (status != PRO_TK_NO_ERROR)
return (status);

// Set parameter type and value.
for(i=0; i<7; i++)
{
if(i == 0) ProStringToWstring(name, "DESCRIPTION");
if(i == 1) ProStringToWstring(name, "NUMBER");
if(i == 2) ProStringToWstring(name, "RESPONSIBLE_DEPARTMENT");
if(i == 3) ProStringToWstring(name, "TAKE_OVER_DEPARTMENT");
if(i == 4) ProStringToWstring(name, "PRODUCTTYPE");
if(i == 5) ProStringToWstring(name, "PROJECTID");
if(i == 6) ProStringToWstring(name, "REVISIONTEXT");
value.type = PRO_PARAM_STRING;

// Make model current obj
status = ProMdlToModelitem (solid, &modelitem);
status = ProParameterInit(&modelitem, name, ¶m);

// If the parameter doesn't exist in the model, create it in the model
// with empty string. Otherwise get its current value.
if (status == PRO_TK_E_NOT_FOUND)
{
ProStringToWstring(value.value.s_val, ");
status = ProParameterCreate (&modelitem, name, &value, ¶m);
}
else
{
status = ProParameterValueGet(¶m, &value);
}

ProWstringToString(astr, value.value.s_val);

// Make drawing current obj
status = ProMdlToModelitem ((ProMdl)drawing, &modelitem);
status = ProParameterInit(&modelitem, name, ¶m);

// If the parameter doesn't exist in drw, create it with empty string.
// Otherwise set it's value to the same as from the model.
ProStringToWstring(value.value.s_val, astr);
if (status == PRO_TK_E_NOT_FOUND)
{
status = ProParameterCreate (&modelitem, name, &value, ¶m);
}
else
{
status = ProParameterValueSet(¶m, &value);
}
}


Tommy
Announcements
Attention: Creo 7.0 Customers
Please consider upgrading
End of Life announcement here.

NEW Creo+ Topics:
PTC Control Center
Creo+ Portal
Real-time Collaboration