Delete specific drafting curves with Journal
Delete specific drafting curves with Journal
(OP)
I can get this to work with the majority of files, but the occassional one does not work and I'm not sure why.
I have a simple if/then statement that if a part attribute has a certain value, then to delete three curves and four notes from two separate sheets within a drawing. These curves and notes are in the exact location in every file.
Any ideas on how to do this 100% of the time? Thanks in advance.
I have a simple if/then statement that if a part attribute has a certain value, then to delete three curves and four notes from two separate sheets within a drawing. These curves and notes are in the exact location in every file.
Any ideas on how to do this 100% of the time? Thanks in advance.





RE: Delete specific drafting curves with Journal
What does your attribute value test look like, what values don't work that you think should?
How are you currently specifying which curves/notes to delete?
You might consider giving these objects custom names or attributes that you could search for when the journal runs. Another option would be to put all the objects of interest into a named group, then delete the objects in the group depending on the part attribute value.
www.nxjournaling.com
RE: Delete specific drafting curves with Journal
I get an error saying No object found with this name.
What I did was recorded a journal, selected the lines and notes, deleted, and stopped recording. I'm pretty sure it just can't find the specified objects in every file.
The if/then statement is simple...
strDWG_STATUS = workPart.GetStringAttribute("DWG_STATUS")
if strDWG_STATUS = "PRELIMINARY" then
'''''NX AUTOMATED CODE'''''
I like the idea of giving a custom name to the lines/notes or grouping them together into a custom named group and deleting that. Could you elaborate further on direction?
RE: Delete specific drafting curves with Journal
Let's say I combined them into a group called "DWG_STATUS_TAB", how would I delete?
RE: Delete specific drafting curves with Journal
CODE
www.nxjournaling.com
RE: Delete specific drafting curves with Journal
That worked great. I appreciate it.
One thing I failed to mention though is that the "DWG_STATUS_TAB" I'm trying to delete actually exists on multiple drawing sheets. When I run this, it only deletes the tab on the first sheet. I have to run it again for it to delete it on the next. Is there a way for it to A) look for it on all sheets and then delete all or B) loop until the Group name can no longer be found?
RE: Delete specific drafting curves with Journal
In the new version, we'll keep track of the groups that we want to delete (by way of a list object); then after the loop has completed cycling through all the group objects, we'll delete the ones we found.
CODE
'http://www.eng-tips.com/viewthread.cfm?qid=359903 'find a group with a given name ' delete the members and the group 'February 14, 2014 Option Strict Off Imports System Imports System.Collections.Generic Imports NXOpen Imports NXOpen.UF Module group_delete Sub Main() Dim theSession As Session = Session.GetSession() Dim theUfSession As UFSession = UFSession.GetUFSession Dim workPart As Part = theSession.Parts.Work Const targetGroup As String = "DWG_STATUS_TAB" Dim groupsToDelete As New List(Of Group) Dim groupTag As NXOpen.Tag = NXOpen.Tag.Null Dim myGroup As Group 'use Do loop to find all groups with the given name Do theUfSession.Obj.CycleObjsInPart(workPart.Tag, UFConstants.UF_group_type, groupTag) 'skip the initial null tag If groupTag = NXOpen.Tag.Null Then Continue Do End If myGroup = Utilities.NXObjectManager.Get(groupTag) If myGroup.Name.ToUpper = targetGroup Then groupsToDelete.Add(myGroup) End If Loop Until groupTag = NXOpen.Tag.Null 'delete all the groups that we found theSession.UpdateManager.ClearErrorList() Dim markId1 As Session.UndoMarkId markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Delete group") Dim nErrs1 As Integer nErrs1 = theSession.UpdateManager.AddToDeleteList(groupsToDelete.ToArray) Dim nErrs2 As Integer nErrs2 = theSession.UpdateManager.DoUpdate(markId1) End Sub End Modulewww.nxjournaling.com
RE: Delete specific drafting curves with Journal
Works like a charm... Thanks a million!
You've never left me hanging. Do appreciate it. If you're ever in Chicago, I owe you a beer!
RE: Delete specific drafting curves with Journal
I modified the below journal line:
Const targetGroup As String = "DWG_STATUS_TAB"
to say:
Const targetGroup As String = "MD*"
but it doesn't work. It gives no errors. If I change it to something like:
Const targetGroup As String = "MD.2000.0055-1"
it will delete the group with that name. Why doesn't the wildcard take care of this?
Thanks for any help you can give me,
Matt
RE: Delete specific drafting curves with Journal
In this context, the '*' character doesn't act as a wildcard, it is simply another character in the string. If you want to delete any group that includes MD, you could change the following lines of code as follows:
CODE
However, if the'*' character did act as a wildcard, your code would only delete the groups whose names started with "MD". If this is what you want, use the .StartsWith method rather than the .Contains method.
If needed, you can use regular expressions in the code which would allow you to get really specific. For instance, delete all the groups that start with MD followed by a 4 digit number less than 2000.
www.nxjournaling.com
RE: Delete specific drafting curves with Journal