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

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

Translate the entire conversation x

How to Automatically Add Dimensions Using Web.Link

RN_12851263
5-Regular Member

How to Automatically Add Dimensions Using Web.Link

Hi everyone,

I am new to Creo Web.Link and currently working on automating the process of adding dimensions to a drawing view. My goal is to:

  1. Check if the current model is a drawing.

  2. Allow the user to select a view in the drawing.

  3. Retrieve model annotations (dimensions) from the selected view and display them.

I am trying to use the Web.Link API, but I am facing issues with retrieving and displaying the dimensions. Here’s the function I have so far:

function addDimension() {
if (pfcIsMozilla())
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");

try {
var session = pfcGetProESession();
var drawing = session.CurrentModel;

if (drawing.Type !== pfcCreate("pfcModelType").MDL_DRAWING) {
alert("Current model is not a drawing.");
return;
}

alert("Drawing detected. Please select a view.");

// Allow user to select a view
var selectedView = drawing.SelectView("Select a view to retrieve dimensions:");

if (!selectedView) {
alert("No view selected.");
return;
}

alert("View selected: " + selectedView.Name);

// Retrieve dimensions from the selected view
var annotations = selectedView.ListAnnotations();
if (annotations.length === 0) {
alert("No annotations found in this view.");
return;
}

alert("Number of dimensions found: " + annotations.length);

// Display the annotations (for testing)
for (var i = 0; i < annotations.length; i++) {
alert("Annotation " + (i + 1) + ": " + annotations[i].Text);
}

} catch (error) {
alert("Error: " + error.message);
}
}

Issues I am Facing:

  • How can I retrieve and display dimensions properly?

  • Is there a way to automatically add dimensions if they don’t exist?

  • Am I missing any required Web.Link methods?



1 REPLY 1

Hi RN_12851263

Thank you for your question. 

Your post appears well documented but has not yet received any response. I am replying to raise awareness. Hopefully, another community member will be able to help.
 

Also, feel free to add any additional information you think might be relevant. It sometimes helps to have screenshots to better understand what you are trying to do.

 

Best regards,


Catalina
PTC Community Moderator
PTC
Announcements

Top Tags