create groups by color journal
create groups by color journal
(OP)
Hi guys,
I have to work with extremely big step files, around 450 mB (usually molds), which have hundreds of bodies. All of them in layer 1… so I can’t filter them by layer, but luckily I do can filter them by color. My intention is to make groups by color with bodies, so then I can work with each group to extract “center lines” in cylinders (each color represents different pipe´s circuit, that’s why I want them separately). My idea is to group them all, and then hide them or deactivate them (it will depend on group type… feature ones or simple groups)
Does anyone knows or have a journal that can do this “group by color” automatically?
I can do it manually, but it takes hours, because each time I filter out and create a group it takes between 10 to 15 minutes (and there are plenty of them).
And after that I have to extract curves…
Another way could be “create components by color”, so once colored bodies belong to each component, I could work on them individually.
Any help will be really helpful. Because I have been working this manually, but I think this should be done faster.
THANKS IN ADVANCE!
I have to work with extremely big step files, around 450 mB (usually molds), which have hundreds of bodies. All of them in layer 1… so I can’t filter them by layer, but luckily I do can filter them by color. My intention is to make groups by color with bodies, so then I can work with each group to extract “center lines” in cylinders (each color represents different pipe´s circuit, that’s why I want them separately). My idea is to group them all, and then hide them or deactivate them (it will depend on group type… feature ones or simple groups)
Does anyone knows or have a journal that can do this “group by color” automatically?
I can do it manually, but it takes hours, because each time I filter out and create a group it takes between 10 to 15 minutes (and there are plenty of them).
And after that I have to extract curves…
Another way could be “create components by color”, so once colored bodies belong to each component, I could work on them individually.
Any help will be really helpful. Because I have been working this manually, but I think this should be done faster.
THANKS IN ADVANCE!





RE: create groups by color journal
If there are a lot of colors, then for sure you need a more advanced program that cycles through everything.
Mark Rief
NX CAM Customer Success
Siemens PLM Software
RE: create groups by color journal
CODE
Option Infer On Imports Snap, Snap.Create Public Class MyProgram Public Shared Sub Main() Dim workPart As Snap.NX.Part = Snap.Globals.WorkPart Dim groupArray(216) As NXOpen.Group For index = 1 To 216 Dim groupName As String = "GROUP_" & index.ToString groupArray(index) = NewGroup(groupName) Next For Each obj As Snap.NX.NXObject In workPart.Objects If obj.HasDisplayProperties Dim colorIndex As Integer = Snap.Color.ColorIndex(obj.Color) AddToGroup(groupArray(colorIndex), obj) End If Next End Sub Public Shared Function NewGroup(groupName As String) As NXOpen.Group Dim theSession = NXOpen.Session.GetSession Dim workPart = theSession.Parts.Work Dim builder = workPart.CreateGatewayGroupBuilder(Nothing) builder.ActivegroupOption = True builder.ActionType = 0 builder.GroupDisplayProperties = False builder.GroupName = groupName Dim group1 As NXOpen.Group = builder.Commit() builder.Destroy() Return group1 End Function Public Shared Sub AddToGroup(group As NXOpen.Group, obj As NXOpen.TaggedObject) Dim theSession = NXOpen.Session.GetSession Dim workPart = theSession.Parts.Work Dim builder = workPart.CreateGatewayGroupBuilder(group) builder.ActivegroupOption = True builder.ActionType = 4 Dim added As Boolean = builder.ObjectsInGroup.Add(obj) builder.Commit() End Sub End ClassRE: create groups by color journal
JUST IN CASE... IS IT POSSIBLE THIS JOURNAL CREATES FEATURE GROUPS INSTEAD OF SIMPLE GROUPS?
IF YOU TELL ME HOW TO EDIT IT I COULD TRY, DONT WANT YOU TO THINK I DONT WANT TO WORK ON IT.
THANK YOU AGAIN!!!
RE: create groups by color journal
RE: create groups by color journal
I looked in all the usual and obvious places, and I can't find the function to create a Feature Group. If you can find the function, you need to plug it into the NewGroup and AddToGroup functions in my code.
Sorry I can't be of more help.
Another option you might try -- organising your objects by layer might work better than using groups.
RE: create groups by color journal
' -----------------------------------------------------------------------------------------
' Creating Feature Group
' -----------------------------------------------------------------------------------------
myTagArray(0) = MyTag
Dim fGroup As Tag = Tag.Null
ufs.Modl.CreateSetOfFeature("MILL_ON", myTagArray, 1, 0, fGroup)
RE: create groups by color journal
If a "set of features" is the same thing as a "feature group", then this should work. However, there does not seem to be any function for adding an object to a "feature group". So you'll have to gather together all the features of a given color in some temporary data structure, and create the group after the gathering stage is finished.
Regarding whether or not it will work "in SNAP". There's really no such thing as "in SNAP". SNAP isn't a language like GRIP or KF, it's just a library of functions. You can call SNAP functions (along with functions from any other library you choose) in any VB program.
RE: create groups by color journal
Suresh
www.technisites.com.au
RE: create groups by color journal
RE: create groups by color journal
Suresh
www.technisites.com.au