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

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

J-Link - delete Layer causes Creo crash

Eike_Hauptmann
13-Aquamarine

J-Link - delete Layer causes Creo crash

Hi everyone,


I have a small Problem. I wan't to delete all Layers with a simple ListLayers(). Iterate through and make Layer.Delete().


Everything fine and the sun is shining.


BUT if there is a Layer named "Hidden Items" (would be created by Creo if u Hide an Element in ModelTree) then the function may crash. It only may crash. The chance to crash is higher if u look in Layertree as if u look in modeltree. And everything is very strange, because it isn't everytime.


Without the Layer everything works perfekt.


Do someone know a way to do it without a possible Creo crash? or have a possibility to look if the "Hidden Items" Layer exists?



Looking forward to hearing from you,


Eike

8 REPLIES 8

From Lyle Beidler :


I would put an exception in your code for it to NOT delete layer “Hidden Items” as this layer is created by Pro/E (Creo), rather than the user. It is the layer that stuff gets added to when you right-click > Hide on an item.



If you’re iterating through the layers, then I’d simply do something like this



String layers[] = <the list=" of=" layer=" names=">


For (int i=0, i<layers.length, i++)<=" p=">

{


if (!layers[i].equals(“Hidden Items”)


{<delete the=" layer=">


}


}



(I’m sure that isn’t the code you are using, but you get the idea)



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


Thx for the answer.



Problem is that I don't get the "Hidden Items" Layer. Creo crashes and don't mind wich Layer I delete.


Example:


I have following Layers in my Tree:


Hidden Items


Layer_001


Layer_002


Layer_003


I delete Layer_001 and Creo crash. If I'm in the ModelTree may be or may be not crash. It's a pitty.



Looking forward to reading from u,


Eike

Maybe you should remove all the items from the layer first?

Patrick Williams | Engineering Systems | o: 616.698.3766 | c: 616.947.2110
[cid:image001.jpg@01CC4788.0E0450F0]

But if the Layer can be deleted when the "Hidden Items" Layer doesn't exists. Why it can't be deleted when it exists. But I will test it. Can be the workaround i search.


Thx Patrick.


Best regards,


Eike

Ok I've tested it. And it also happens if the Layers are empty. I test it to create an empty one, and i also test to create one with elements on it and clear it programmaticly before I let it delete. Everytime Creo or WF5 goes to heaven.


Here is my simple samplecode:


ModelItems lays = mdl.ListItems(ModelItemType.ITEM_LAYER);
for (int j = 0; j < lays.getarraysize(); j++) {
System.out.println("delete " + ((Layer)lays.get(j)).GetName());
((Layer) lays.get(j)).Delete();
}



PTC C10411935 (Creo Parametric): J-Link - delete Layer crash Creo / Pro/E if "Hidden Items" Layer exists

I have had similar issues with the toolkit. I'm afraid I can offer no help, save to confirm that the "Hidden Items" layer does NOT turn up on when visiting all layers (using ProMdlLayerVisit). This has been confirmed to me by the PTC support person assigned to my case.

Hi,



PTC has accepted the issue and I get an SPR.


"Your caseC10411935has been forwarded on to our development team under reference number SPR2094697 with <high> priority."


If someone is interested. I have checked the issue are in Toolkit, J-Link and Web/Link the same.



Best Regards,


Eike

Hi folks,


here is the solution, get it from Feliks.


Just use these Code


if(PRO_TK_NO_ERROR == ProModelItemByNameInit());
ProLayerDelete();


I test it at Toolkit and it work very well. (Layertree isn't updated, so you don't see it atm, but if you create a new layer the old layers that deleted disappear)



Thanks very much to Feliks.



Best regards,


Eike

FV
17-Peridot
17-Peridot
(To:Eike_Hauptmann)

Hi all,


For complitness sake, if someoneneeds to copy-paste Pro/Toolkit code.


ProError del_lay( ProMdl mdl, ProName lay_name)


{


ProLayer lay;


ProError err = PRO_TK_GENERAL_ERROR;


if( PRO_TK_NO_ERROR == ProModelitemByNameInit( mdl, PRO_LAYER, lay_name, (ProModelitem*) &lay)){


err = ProLayerDelete( &lay);


}


if( PRO_TK_NO_ERROR == err) {


int tmp_id = -1;


//to refresh layer tree, undocumented behavior in full sync mode


ProWindowCurrentGet( &tmp_id);


ProWindowActivate( tmp_id);


}


return(err);


}


HIH.


Feliks.

In Reply to Eike Petersen:



Hi folks,


here is the solution, get it from Feliks.


Just use these Code


if(PRO_TK_NO_ERROR == ProModelItemByNameInit());
ProLayerDelete();


I test it at Toolkit and it work very well. (Layertree isn't updated, so you don't see it atm, but if you create a new layer the old layers that deleted disappear)



Thanks very much to Feliks.



Best regards,


Eike


Top Tags