cancel
Showing results for 
Search instead for 
Did you mean: 

PMI annotations I create in NXOpen crash NX if Settings are looked at

Pioneer
Pioneer

I'm working on a Python tool with NXOpen to manage embedded PMI notes, and I've run into a repeatable crash issue.  Whenever I look at the Settings (double click then click Settings icon) of a PMI Annotation I created using the script, it crashes NX.  Error message is "Unhandled operating system exception: e06d7363"  So far I have only worked on creating PartIdentification typed notes - I don't want to move forward to the other types until I can resolve these crashes.

First dialog box that pops up:

Fatal error ... e06d7363Fatal error ... e06d7363

Second dialog box that pops up:

Initialization - COLLAPSEInitialization - COLLAPSE

That dialog box is really confusing because my D drive is my DVD reader (which is broken, but that shouldn't matter to NX).  So that filepath goes nowhere.

This crash/error does not appear when I look at the Settings on PartIdentification objects that already exist.

This crash/error does not appear when I look at the Settings on PartIdentification objects that I create manually through the normal ribbon interface.

I assume my script is missing something that is important to the health of the PartIdentification object - does anyone have any ideas?  It doesn't crash when the object is created, just when it is queried later after I've closed out of the dialog box.

6 REPLIES

Re: PMI annotations I create in NXOpen crash NX if Settings are looked at

Phenom
Phenom

Can you post the relevant code?

I assume that you are using a PMI note builder object; do you validate the input before committing and do you destroy the builder object after the note is created?

Re: PMI annotations I create in NXOpen crash NX if Settings are looked at

Esteemed Contributor
Esteemed Contributor

Note (I think) the "D:\..." path is where the source file was located when the developer compiled/linked their code.  It has nothing to do with your PC.

 

 

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP5 + patch/TC11.2
I'd rather be e-steemed than e-diseaseled


Re: PMI annotations I create in NXOpen crash NX if Settings are looked at

Pioneer
Pioneer

Some relevant code is below, I've removed sensitive portions and replaced with #....  There are a lot of lines here that I copied from recorded Journals to attempt to stop the crashing.  I do not validate the builder before committing, but I do make sure to destroy it when I'm done.  Often in this code I am making a builder just to extract information, and I don't commit it, but I do destroy it.

def formatThisBuilder(self, thisTitle, thisBuilder):
#...
    noteSpecificFormatting = self.ctrlNoteProps[thisTitle]
    campusSpecificFormatting = self.campusDefaults[self.mySetCampus]
    thisBuilder.Origin.SetInferRelativeToGeometry(True) 
    thisBuilder.Origin.Plane.PlaneMethod = NXOpen.Annotations\
            .PlaneBuilder.PlaneMethodType.ModelView
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ### This section contain settings that aren't used but that
    ### seem to prevent crashes from happening if the PMI note
    ### is asked for its properties later
    leaderData1 = self.theWorkPart.Annotations.CreateLeaderData()    
    leaderData1.StubSize = 0.25    
    leaderData1.Arrowhead = NXOpen.Annotations.LeaderData.ArrowheadType.FilledArrow    
    leaderData1.VerticalAttachment = NXOpen.Annotations.LeaderVerticalAttachment.Center    
    thisBuilder.Leader.Leaders.Append(leaderData1)    
    leaderData1.StubSide = NXOpen.Annotations.LeaderSide.Inferred

    assocOrigin1 = NXOpen.Annotations.Annotation.AssociativeOriginData()    
    assocOrigin1.OriginType = NXOpen.Annotations.AssociativeOriginType.Drag
    assocOrigin1.View = NXOpen.View.Null
    assocOrigin1.ViewOfGeometry = NXOpen.View.Null
    assocOrigin1.PointOnGeometry = NXOpen.Point.Null
    assocOrigin1.VertAnnotation = NXOpen.Annotations.Annotation.Null
    assocOrigin1.VertAlignmentPosition = NXOpen.Annotations.AlignmentPosition.TopLeft
    assocOrigin1.HorizAnnotation = NXOpen.Annotations.Annotation.Null
    assocOrigin1.HorizAlignmentPosition = NXOpen.Annotations.AlignmentPosition.TopLeft
    assocOrigin1.AlignedAnnotation = NXOpen.Annotations.Annotation.Null
    assocOrigin1.DimensionLine = 0
    assocOrigin1.AssociatedView = NXOpen.View.Null
    assocOrigin1.AssociatedPoint = NXOpen.Point.Null
    assocOrigin1.OffsetAnnotation = NXOpen.Annotations.Annotation.Null
    assocOrigin1.OffsetAlignmentPosition = NXOpen.Annotations.AlignmentPosition.TopLeft
    assocOrigin1.XOffsetFactor = 0.0
    assocOrigin1.YOffsetFactor = 0.0
    assocOrigin1.StackAlignmentPosition = NXOpen.Annotations.StackAlignmentPosition.Above
    thisBuilder.Origin.SetAssociativeOrigin(assocOrigin1)
    
    ### End of section of ignorable settings
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    
    thisBuilder.Style.LetteringStyle.GeneralTextSize = round(
            float(campusSpecificFormatting['textHeightPMI']) * \
            float(noteSpecificFormatting['FontScale']), 3)   
    thisBuilder.Style.LetteringStyle.GeneralTextFont = self.fontNumber
    chosenWidth = self.textColorFontWidthNewEmbeddedPMI.WidthValueAsString
    if chosenWidth == 'Thin Width':
        thisBuilder.Style.LetteringStyle.GeneralTextLineWidth = \
         NXOpen.Annotations.LineWidth.Thin
    elif chosenWidth == 'Thick Width':
        thisBuilder.Style.LetteringStyle.GeneralTextLineWidth = \
         NXOpen.Annotations.LineWidth.Thick
    else: #'Normal Width'
        thisBuilder.Style.LetteringStyle.GeneralTextLineWidth = \
         NXOpen.Annotations.LineWidth.Normal           
    thisBuilder.Style.LetteringStyle.GeneralTextColor = \
            self.textColorFontWidthNewEmbeddedPMI.GetColorValue
    self.logInfoList.append('g ')
    thisBuilder.Origin.Anchor = eval(noteSpecificFormatting['Anchor'])
    self.logInfoList.append('h ')
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ### This section is entirely to figure out where to place
    # the origin of the note in model space
#...
        mX = round(mX, 3)
        mY = round(mY, 3)
        mZ = round(mZ, 3)

        thisOrigin = NXOpen.Point3d(mX, mY, mZ)
        thisBuilder.Origin.Origin.SetValue(
                NXOpen.TaggedObject.Null, NXOpen.View.Null, thisOrigin)
    self.logInfoList.append('j ')
    ### End of section to place origin of note object
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    try:
        body1 = self.selectAssociatedPartsBodies.GetSelectedObjects()[0]
        added1 = thisBuilder.AssociatedObjects.Nxobjects.Add(body1)
    except:
        pass

    return(thisBuilder)
def invokePartIDBuilder(self):
    if 'PartID' in self.PMIDefined:
        onePMIAttributeObject = NXOpen.TaggedObjectManager\
                .GetTaggedObject(self.PMIDefined['PartID']['exTag'])
        partIDBuilder1 = self.theWorkPart.PmiManager.PmiAttributes\
                .CreatePartIdentificationBuilder\
                (onePMIAttributeObject)
    else:
        self.PMIDefined['PartID'] = {}
        partIDBuilder1 = self.theWorkPart.PmiManager.PmiAttributes\
                .CreatePartIdentificationBuilder\
                (NXOpen.Annotations.PartIdentification.Null)
    partIDBuilder1 = formatThisBuilder(self, 'PartID',
                                       partIDBuilder1)
    return(partIDBuilder1)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~            
            elif block == self.stringIDPartNo:
#...
                partIDBuilder1 = invokePartIDBuilder(self)
                newIDString = self.stringIDPartNo.Value
                partIDBuilder1.PartIdentifier = newIDString                
                self.PMIDefined['PartID']['newID'] = \
                                partIDBuilder1.PartIdentifier                
                nXObject1 = partIDBuilder1.Commit()
                self.PMIDefined['PartID']['exTag'] = nXObject1.Tag
                partIDBuilder1.Destroy()
            #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Re: PMI annotations I create in NXOpen crash NX if Settings are looked at

Pioneer
Pioneer

(Deleting duplicate post, trying not to destroy anyone elses' replies to this post...)

Re: PMI annotations I create in NXOpen crash NX if Settings are looked at

Pioneer
Pioneer

I've added a step to validate the builder before committing it.  It passes, and then it still crashes when I try to view the Settings for the Part Identification note created.

try:
    partIDBuilder1.Validate()
except Exception as ex:
    self.theUI.NXMessageBox.Show("partIDBuilder1 Validation",
        NXOpen.NXMessageBox.DialogType.Error,
        str(ex))
nXObject1 = partIDBuilder1.Commit()

I also confirmed that using a right click to go into Settings also causes the same exact crash.

 

Re: PMI annotations I create in NXOpen crash NX if Settings are looked at

Pioneer
Pioneer

I got it to stop crashing!  These are the lines I added to or changed in the formatThisBuilder function between when it wasn't working and when it was working:

thisBuilder.Style.LetteringStyle.GeneralTextAspectRatio = 1.0
thisBuilder.Style.LetteringStyle.GeneralTextCharSpaceFactor = 1.0
thisBuilder.Style.LetteringStyle.GeneralTextLineSpaceFactor = 1.0
#...
chosenColorNumber = self.textColorFontWidthNewEmbeddedPMI.GetColorValue()[0]
colorObject = self.theWorkPart.Colors.Find(chosenColorNumber)
thisBuilder.Style.LetteringStyle.GeneralTextColor = colorObject

I suspect there was something wrong (upsetting to NX) with the one-line color value assignment I was trying to do before.  So I copied a "clunky" block of code from another script that I know works, and that works here, too. 

Earlier, I added this line as a catch-all, but it wasn't enough to stop the crashing:

thisBuilder.Style.InheritSettingsFromPreferences()

So that made me suspicious of the things I was setting, rather than things I was missing. 

Lesson learned: stop trying to optimize everything, sometimes NX likes having things on separate lines.