Macro for changing objects on all layers to specified colors
Macro for changing objects on all layers to specified colors
(OP)
NX 6.0.3.6
Windows 7 Pro
Hello all,
I am trying to make a macro that will perform the following function:
<Start from a file that objects on some or all layers with all layers turned off>
1. Turn all layers on.
2. Set TFR-ISO view (fitting all to screen.
3. Edit Object Display.
4. Select all objects on one layer (ex. 21).
5. Change Color to specific layer number.
6. Apply change.
7. Select New Objects.
8. Loop back to #4 until objects on all 256 layers have been assigned a predetermined color.
9. Close dialog and end macro.
Additional criteria:
- Must not fault if no objects exist on specified layer.
I uploaded a shortened attempt at this concept that goes for layers 21 through 25 changing all objects to color #36 for each layer. One issue with the macro is that it doesn't change any layer color accept the last on the list (not sure why). Another issue being that it faults when no objects are present.
I would appreciate any assistance you can lend. If I'm going about this all the wrong way, feel free to let me know.
Thank you,
Windows 7 Pro
Hello all,
I am trying to make a macro that will perform the following function:
<Start from a file that objects on some or all layers with all layers turned off>
1. Turn all layers on.
2. Set TFR-ISO view (fitting all to screen.
3. Edit Object Display.
4. Select all objects on one layer (ex. 21).
5. Change Color to specific layer number.
6. Apply change.
7. Select New Objects.
8. Loop back to #4 until objects on all 256 layers have been assigned a predetermined color.
9. Close dialog and end macro.
Additional criteria:
- Must not fault if no objects exist on specified layer.
I uploaded a shortened attempt at this concept that goes for layers 21 through 25 changing all objects to color #36 for each layer. One issue with the macro is that it doesn't change any layer color accept the last on the list (not sure why). Another issue being that it faults when no objects are present.
I would appreciate any assistance you can lend. If I'm going about this all the wrong way, feel free to let me know.
Thank you,
John B. Conger
Tool Design
Automotive Interiors
Advanced Engineering Solutions Inc.
http://www.advancedinternational.com/





RE: Macro for changing objects on all layers to specified colors
RE: Macro for changing objects on all layers to specified colors
www.nxjournaling.com
RE: Macro for changing objects on all layers to specified colors
CODE
Or, as a downloadable file
www.nxjournaling.com
RE: Macro for changing objects on all layers to specified colors
Best Regards,
John B. Conger
Tool Design
Automotive Interiors
Advanced Engineering Solutions Inc.
http://www.advancedinternational.com/
RE: Macro for changing objects on all layers to specified colors
The Journal Worked! I applied our color standards to each layer and ran the journal file. The first attempt didn't work. I was getting an error on the line shown below:
displayModification1.ApplyToOwningParts = False
ApplyToOwningParts was not a valid function of the library. I commented the line and ran it again. All worked well. I do have a question though. What was the purpose of that line?
I linked the finished file for you to look over and see what the result was. Please review and let me know what you think.
Thanks again,
John B. Conger
Tool Design
Automotive Interiors
Advanced Engineering Solutions Inc.
http://www.advancedinternational.com/
RE: Macro for changing objects on all layers to specified colors
For the displayModification part, I recorded a journal and did a copy/paste job into my code. The "ApplyToOwningParts" bit was added in NX 7.5, since you are running NX 6 that is why you get the error. Commenting it out should have no affect on what you are doing, I believe it is more useful when working in the context of an assembly.
I also just noticed that I specified a trimetric view when you asked for an isometric view. You can change this line of code to get what you want.
CODE
www.nxjournaling.com
RE: Macro for changing objects on all layers to specified colors
Best Regards,
John B. Conger
Tool Design
Automotive Interiors
Advanced Engineering Solutions Inc.
http://www.advancedinternational.com/