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

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

SOLVED
Highlighted
Newbie

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

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 !

Tags (3)
1 ACCEPTED SOLUTION

Accepted Solutions

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

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.

13 REPLIES 13

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

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

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

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

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

Thank you ~ I'll try that tomorrow ~

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

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"?

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

Sorry , I was busy in the past few days.

Still no progress . I recorded a macro which can color selected surfaces green when I press "F1", but it doesn't work when I try it in j-link code.

I got that a sequence of "item" using "ItemOwner.ListItems()" function , now I am using visual selection. Here is the code:

-------------Java Code------------------

Selections Slection;

SelectionOptions Slect_Option = null;

try

{

Slect_Option = pfcSelect.SelectionOptions_Create("sldface");

Slect_Option.SetMaxNumSels(-1);

} catch (Throwable e)

{

System.out.println("Exception caught in initializing options !" + e);

}

int num;

Slection = proESession.Select(Slect_Option, null);

proESession.LoadConfigFile("F:\\config.pro");

proESession.RunMacro("IBS");

-------------Java Code------------------

Here is the content of file config.pro:

-------------config.pro------------------

mapkey $F1 @MAPKEY_LABELIBSS;\

mapkey(continued) ~ Select `main_dlg_cur` `ProCmdViewGallery.view`;\

mapkey(continued) ~ Select `main_dlg_cur` \

mapkey(continued) `ProCmdViewGallery_layoutph.palette_holder.modelPalette.NamesList`1 \

mapkey(continued) `ptc-painted-green`;~ Timer `UI Desktop` `UI Desktop` `Gallery_UI_Timer`;\

mapkey(continued) ~ Close `main_dlg_cur` `ProCmdViewGallery.view`;

-------------config.pro------------------

Any infomation about how to write a better macro ? Or in fact the macro simply didn't got called ?

And , is there any way to color all the surfaces in the part red ?

Help ...I am getting crazy about it ...

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

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.

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

Well, it seems I've understood the user guide incorrectly ...

Thank you ~ I am working on these new code ...

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

That's a great idea , I've got what I want !

Besides , I improved your way to avoid a flashing window : store the appearance configuration contain the color to the file "appearance.dmt" file placed under the pro/E start directory ,so pro/E would load the appearance configuration automaticly. Then just use a simple macro like:

session.RunMacro("mapkey $F1 @MAPKEY_LABELIBSS;\"

"mapkey(continued) ~ Select `main_dlg_cur` `ProCmdViewGallery.view`;\"

"mapkey(continued) ~ Select `main_dlg_cur` \"

"mapkey(continued) `ProCmdViewGallery_layoutph.palette_holder.modelPalette.NamesList`1 \"

"mapkey(continued) `ptc-painted-green`;~ Timer `UI Desktop` `UI Desktop` `Gallery_UI_Timer`;\"

"mapkey(continued) ~ Close `main_dlg_cur` `ProCmdViewGallery.view`;")

You can color the surfaces in the selection buffer without flashing the window !

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

I tried using a macro like your, but without success. Was problem with slash "\" in string. How do you avoid this? Posted here code works?