cancel
Showing results for 
Search instead for 
Did you mean: 
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 ?

ptc-4824040
1-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 !

1 ACCEPTED SOLUTION

Accepted Solutions

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.

View solution in original post

13 REPLIES 13

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

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

Thank you ~ I'll try that tomorrow ~

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

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

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.

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

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

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 !

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?

No ... The working code was in another computer which doesn't have an internet connection , I just copied the code above ...

I'll post you the working code later .

Here is the working code:

Surfaces burnSurfaces = SurfacesSelector.SelectSurfaces_Negative(curModel, -1, proESession);

//My function to select surfaces

if (burnSurfaces != null)

{

SelectionBuffer selectionBuffer;

selectionBuffer = proESession.GetCurrentSelectionBuffer();

for (int i = 0; i < burnSurfaces.getarraysize(); ++i)

{

selectionBuffer.AddSelection(pfcSelect.CreateModelItemSelection((ModelItem) burnSurfaces.get(i), null));

}

proESession.RunMacro("mapkey $F3 ~ Select `main_dlg_cur` `ProCmdViewGallery.view`;"

+ "mapkey(continued) ~ Select `main_dlg_cur` `ProCmdViewGallery_layoutph.palette_holder.myAppPalette.NamesList`1 `unburnsurface`;"

+ "mapkey(continued) ~ Timer `UI Desktop` `UI Desktop` `Gallery_UI_Timer`;"

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

}

}

I found the slash "\" annoying and deleted them. You have to use double slash "\\" to tell Java compiler that "here is a slash". Or error would occur even before you run the code.

Earlier I dreamed about tool to color a whole surface of a feature in one click. Do you doing some thing like this?

Not now , I just need to color them to a specific RGB value ...

I guess you can try to keep "getParentModelItem()" until you get a "feature" , then list all surfaces and color them.

Announcements