16 Replies Latest reply on Mar 7, 2018 12:15 PM by Peter Debono

    Nesting Curve Through XYZ / Macro Feature Selection

    Peter Debono

      I have a macro that creates a macro feature in a part file then creates curves through XYZ and makes those curves sub-features of the macro feature. The issue I have is that if the part file is closed the next time it's re-opened the curves are no longer sub-features and I don't know why the sub-feature assignment is lost. Has anyone experienced this issue or know of a fix? I'm using the MakeSubFeature.

       

      CurrentFeat = swModel.Extension.SelectByID2(nameRCrv, "REFERENCECURVES", 0, 0, 0, False, 0, Nothing, 0)

      Set CurrentFeat = swSelMgr.GetSelectedObject6(1, -1)

      BoolStatus = swFeature.MakeSubFeature(CurrentFeat)

       

      Also, is there anyway to highlight the sub-features of a macro feature in the graphics window when that macro feature has been selected in the feature tree? IE when I select the macro feature created by the macro described above, I'd like the curves to be highlighted in the graphics window.

        • Re: Nesting Curve Through XYZ / Macro Feature Selection
          Jacob Corder

          i have only used MakeSubFeature with a macroFeature and another macrofeature. i dont know why curves wouldn't work. 

           

          to highlight subfeatures.

          when a feature is selected. do this

          assume SelectedFeature is assigned

           

          Dim FirstSubFeat as feature

          Set FirstSubfeat = SelectedFeature.getFirstSubFeature

          do until FirstSubfeat is nothing

             do stuff here.

               firstsubfeat= firstsubfeat.getnextsubfeature

          loop

           

          assignment might be lost if your toggling show flat tree view or rolling back and assigning subfeatures. i have had this issue in the past.  it appears that they are not subfeatures, but when you call GetFirstSubFeature on the Macrofeature it will return assigned subfeatures. 

            • Re: Nesting Curve Through XYZ / Macro Feature Selection
              Peter Debono

              Thanks for the sub-feature selection code but I'd prefer not to have to run another macro every time I select the Macro Feature. Ideally all items below the macro feature (2 curves and an attribute) would appear as a single feature in the feature tree (for selection, deletion or editing).

               

              The tree display is not set to show flat and nothing is being rolled back. I'm also creating an attribute to store curve related data which retains its sub-feature relationship. There must be something odd about Curve Through XYZ that doesn't like being a child feature.

                • Re: Nesting Curve Through XYZ / Macro Feature Selection
                  Jacob Corder

                  Thanks for the sub-feature selection code but I'd prefer not to have to run another macro every time I select the Macro Feature. Ideally all items below the macro feature (2 curves and an attribute) would appear as a single feature in the feature tree (for selection, deletion or editing).

                  well.  ideally sure. but it doesn't work that way so we have to make it work the way we want. When i select my parent macrofeatures, no children are selected for me so you will need to handle this with an addin that has a handler attached to Partdoc PreselectionNotify and Partdoc UserSelectionPostNotify.

                   

                  to test if it is just a featuremanager tree issue, or a subfeature issue do the following code

                   

                  select one of the curves

                  Then Dim CurveFeat as feature = get it through selection

                   

                  Dim OwnFeat as feature

                  Set OwnFeat = CurveFeat.getOwnerFeature

                   

                  Does it return the parent macrofeature? 

                  if not it is actually a broken link.

                  if so then it is  just a feature manager tree issue.

                   

                  i think i know what is going on here.  answer the above question

              • Re: Nesting Curve Through XYZ / Macro Feature Selection
                Jacob Corder

                to delete when the parent is deleted

                use

                DPartDocEventsDeleteItemPreNotify and DPartDocEventsDeleteItemNotify to delete the curves.

                 

                in deleteitemprenotify i create a list of items to also delete. and in DeleteItemNotify, i delete the list of items because in deleteitemnotify (when it is already deleted) you dont have access to the feature anymore and you cant delete items in DeleteItemPreNotify (Its not safe)

                • Re: Nesting Curve Through XYZ / Macro Feature Selection
                  Peter Debono

                  There has been an interesting development that may or may not help to determine why the relationship of the curve to the macro feature is lost. When deleting the macro feature, the attribute is listed as a dependent item by default because it's owner feature is assigned during macro creation.

                  The curve isn't listed in the delete confirmation unless "Delete Absorbed Features" is selected

                  Once the file is closed then opened again the absorbed curve is lost... There must be away to set the owner feature of the curve and have that relationship retained.

                    • Re: Nesting Curve Through XYZ / Macro Feature Selection
                      Jacob Corder

                      sadly this wont help. the reason is because that curve cannot be a parent, nor can it be a child.

                       

                      during macrofeature regeneration, you need to assign parents with IMacroFeatureData.SetParents and pretty much every rebuild it needs to be done or the parent child relationship could be come corrupt. 

                       

                      you have no way to set curve.setparents

                       

                      i would suggest that if this is critical, you create your own CurveFeature.  in the end it will be much better for you as you will have full control of the feature. 

                       

                      if a feature like a revolved cut adds a feature as a child, it uses that child feature as a profile to create the cut so it is selected during feature creation.

                       

                      when you create your macrofeature,  Select the Curve before you call CreateMacroFeature3.  it will become a parent, but can be set as a subfeature also possibly.

                       

                       

                       

                      also for repairing current features

                      during regeneration verify selections are correct

                       

                      so IMacroFeatureData.Getselections

                       

                      if the curve isnt there you need to call IMacroFeatureData.SetSelections

                       

                      the selected items must be a DisplatchWrapper()  array

                    • Re: Nesting Curve Through XYZ / Macro Feature Selection
                      Peter Debono

                      Note that I've marked original question as answered, thanks Jacob:

                      - Curve through XYZ cannot be made subfeatures.

                      - Subfeatures cannot be highlighted without creating an addin to capture the event.

                       

                      One side question though. I'd like to know if it's possible to create a macro feature that can be deleted from the macro only. I figured that I can use the macro feature security swMacroFeatureSecurityOptions to allow the macro feature to be deleted when the macro is open and prevent it from being deleted when selected in the feature tree. Is this possible?