Skip to main content
1-Visitor
November 6, 2012
Solved

How to set the color property of a surface using j-link ?

  • November 6, 2012
  • 2 replies
  • 6632 views

As a beginner , I konw this question maybe stupid ,but I've already checked almost all the file that I can get.

 

 

I want to mark some of the surfaces in the model using a color, and the rest of surfaces using the other color.

And, I already successfully got a sequence of "item", but I didn't find any information about how to operate these items in color or material .Will someone give me some suggestion ? Thank you !

Best answer by ysinitsin

First of all, I'm not sure, that is possible to run a macro from config.pro. This method is working fine, for example

proESession.RunMacro("mapkey $F2 ~ Activate `main_dlg_cur` `page_Review_control_btn` 1;"+

"mapkey(continued) ~ Activate `main_dlg_cur` `Review:ProCmdDwgRegenDraft`;"+

"mapkey(continued) ~ Activate `main_dlg_cur` `page_Tools_control_btn` 1;");

Working code:

--------------------------------------------------------------

Model Doc3D;
SelectionBuffer selectionBuffer;

Session session = pfcGlobal.GetProESession();

selectionBuffer = session.GetCurrentSelectionBuffer();
Doc3D = session.GetCurrentModel();
ModelItems Faces = Doc3D.ListItems(ModelItemType.ITEM_SURFACE);
Selection Sel = pfcSelect.CreateModelItemSelection(Faces.get(1), null);

selectionBuffer.AddSelection(Sel);

session.RunMacro("mapkey $F8 ~ Select `main_dlg_cur` `View:ProCmdViewGallery`;"+
"mapkey(continued) ~ Close `main_dlg_cur` `View:ProCmdViewGallery`;"+
"mapkey(continued) ~ Activate `main_dlg_cur` `ProCmdViewGallery_layoutph.appEditorPB`;"+
"mapkey(continued) ~ Activate `pgl_appearance_manager` `ColorButton` 1;"+
"mapkey(continued) ~ Arm `pgl_color_editor` `SBlue`;"+
"mapkey(continued) ~ Update `pgl_color_editor` `SBlue` 100;"+
"mapkey(continued) ~ Disarm `pgl_color_editor` `SBlue` 100;~ Arm `pgl_color_editor` `SGreen`;"+
"mapkey(continued) ~ Update `pgl_color_editor` `SGreen` 0;"+
"mapkey(continued) ~ Disarm `pgl_color_editor` `SGreen` 0;~ Arm `pgl_color_editor` `SRed`;"+
"mapkey(continued) ~ Update `pgl_color_editor` `SRed` 0;~ Disarm `pgl_color_editor` `SRed` 0;"+
"mapkey(continued) ~ Activate `pgl_color_editor` `StdOk`;"+
"mapkey(continued) ~ FocusOut `pgl_appearance_manager` `AppearanceName`;"+
"mapkey(continued) ~ Activate `pgl_appearance_manager` `stdOk`;");

--------------------------------------------------------------

In the example, will change the color only ONE face of the part. I don't like a flashing window. Need to play with a macro.

2 replies

1-Visitor
November 7, 2012

Oh , no ... Anybody can provide some help ?

1-Visitor
November 7, 2012

Thinking out loud. Try to make a mapkey (macro) for changing a color of selected face. Then use pfcSession.BaseSession.RunMacro

1-Visitor
November 7, 2012

Thank you ~ I'll try that tomorrow ~

1-Visitor
November 9, 2012

How is going?

I think, first of all need to select (visual selection in working space) item/surface of a part and then use runmacro.

By the way, can you share a part of code where you got a sequence of "item"?