Journal - Select objects to change layer
Journal - Select objects to change layer
(OP)
Hello Eng-Tips
Attached you will find a journal that move Datums/Curves/Sketch & Sheets to differents layers. The main idea for this journal is to organize any objects in the view. There is an issue I can't find a solution (or a clue at least), after the objects have been move and trying to uncheck the Show/Hide checkbox in "Layer Settings" (Ctrl+L) the objects are still in View; these can be fixed by closing/opening the file but it would be annoying.
BestRegards
Attached you will find a journal that move Datums/Curves/Sketch & Sheets to differents layers. The main idea for this journal is to organize any objects in the view. There is an issue I can't find a solution (or a clue at least), after the objects have been move and trying to uncheck the Show/Hide checkbox in "Layer Settings" (Ctrl+L) the objects are still in View; these can be fixed by closing/opening the file but it would be annoying.
BestRegards





RE: Journal - Select objects to change layer
CODE
www.nxjournaling.com
RE: Journal - Select objects to change layer
Thanks for your response. A few questions, I made some modification to the original code adding some "If Type" sentence to test if the tempObj is Datum Plane, Datum Axis, Datum Point or Datum Coordinate System, all four belong to DatumCollection Class.
I try to declared as such "If TypeOf tempObj Is DatumCOllection Then" and then change the layer but in response I get an error (I found out that layer is not a property of DatumCollection Class); so how could be the code to use DatumCollection to avoid doing four "IF TYPE" check or four "For Each /Next" check as you suggest.
BestRegards
RE: Journal - Select objects to change layer
CODE
This will move all the datum types (plane, axis, point, csys) to the same layer.
However, if you want to separate datum planes to one layer, datum axes to another layer, etc; you'll have to check the type before moving them.
www.nxjournaling.com
RE: Journal - Select objects to change layer
Asper your coding all Sketches, Datums, Curves etc will move in respective Layer. But My question is If I have used 5 sketches in my model, All 5 sketches has to move in different layer like 22,23,24,25 & 26. so, for this how to write coding.
Thanking you.
RE: Journal - Select objects to change layer
As ou suggested, I comment only "If Type" and "EndIf" lines and it only works with planes and axis but not with point and csys. I'm trying to move them separately but not luck so far. Attached you
RE: Journal - Select objects to change layer
RE: Journal - Select objects to change layer
I don't see an attachment...
holyghost,
One strategy would be to increment the sketch layer variable each time through the loop:
CODE
www.nxjournaling.com
RE: Journal - Select objects to change layer
RE: Journal - Select objects to change layer
I strongly suggest working with the collections of objects that the Part gives you access to. This has several advantages:
- it will eliminate the need for many of the If TypeOf... statements
- it returns both visible and hidden objects
- you can control the order the types of objects are processed
The last point is especially important because the system does not differentiate between sketch curves and non-sketch curves. If you move a sketch object then later move a curve object that happens to belong to the sketch, it will remain out of sync until the sketch updates (the sketch will belong to one layer and its curves may belong to another).www.nxjournaling.com
RE: Journal - Select objects to change layer
When I run Layer journal I am getting error as attached jpg
RE: Journal - Select objects to change layer
CODE -->
RE: Journal - Select objects to change layer
Its working fine , But those are not going to under Sketch Category those are going under Curve Category why? How to fix this problem
Thanks
RE: Journal - Select objects to change layer
There are multiple ways to "fix" it, two of which are:
Const SketchLayerStart as Integer = 22
good catch, kfraysur, I didn't test the code before posting it.
www.nxjournaling.com
RE: Journal - Select objects to change layer
thanks
RE: Journal - Select objects to change layer
Everything is fine, But I fixed 15 layers only for sketchs like 21 to 35. Then how to write that ifany sketchs more than 15 , It should popup that sketch limit is crossed.
Thanks.
RE: Journal - Select objects to change layer
CODE -->
Const SketchLayerStart as Integer = 21 'Make 'MaxLayer' the last layer you are willing to move a sketch to Const MaxLayer as Integer = 35 dim i as integer = 0 dim j as integer = SketchLayerStart 'move sketches for each sketchObj as Sketch in workPart.Sketches If j <= MaxLayer sketchObj.Activate(False) sketchObj.Layer = SketchLayerStart + i sketchObj.RedisplayObject sketchObj.Deactivate(False, Sketch.UpdateLevel.SketchOnly) i += 1 j += 1 Else Msgbox("The maximum sketch layer value of: " & MaxLayer & " has been exceeded) End If next