4 bugs (at least) related to Occurrences

4 bugs (at least) related to Occurrences

pludikar
Collaborator Collaborator
3,178 Views
13 Replies
Message 1 of 14

4 bugs (at least) related to Occurrences

pludikar
Collaborator
Collaborator

@marshaltu  @jeff.strater

 

I love F360, but it is clear that the program has not got it's head around occurrences.  A number of bugs have already been fixed - see this thread, but it appears that the symptoms are being addressed and not the underlying cause.  I would venture to suggest that the implementation of occurrences, in general, is broken.

 

The following code highlights at least four issues - and this is just with creating holes.  I believe this is just the tip of the iceberg (other features and anything that has either .createForAssemblyContext or where .creationOccurrence can be written to, to name a few).  I've included the sample model along with a screen cast.

 

import adsk.core, adsk.fusion, traceback

def run(context):
  ui = None
  try:
    app = adsk.core.Application.get()
    ui  = app.userInterface
    
    design = adsk.fusion.Design.cast(app.activeProduct)
    root = design.rootComponent
#Create sketch and circle for component at root level    
    
    def createHole(occurrence, faceNo, vertexNo):
        body = adsk.fusion.BRepBody.cast(occurrence.bRepBodies.item(0))
        face = body.faces.item(faceNo)
        vertex = face.vertices.item(vertexNo)
        point = vertex.nativeObject.geometry
        component = adsk.fusion.Component.cast(occurrence.component)
        sketch = component.sketches.add(face, occurrence)
        pointInSketch = sketch.modelToSketchSpace(point)
        sketchPoint = sketch.sketchPoints.add(pointInSketch)  #as the centre is placed on midline endPoint, it automatically gets constrained

         
        holes =  component.features.holeFeatures
        holeInput = holes.createSimpleInput(adsk.core.ValueInput.createByReal(.5*2.54))
        holeInput.isDefaultDirection = True
        holeInput.creationOccurrence = occurrence # work around if this is commented out!!
        holeInput.tipAngle = adsk.core.ValueInput.createByString('180 deg')
        holeInput.participantBodies = [face.nativeObject.body]
        holeInput.setPositionBySketchPoint(sketchPoint)

#        holeInput.setAllExtent(0)
        holeInput.setDistanceExtent(adsk.core.ValueInput.createByReal(2.0*2.54))

        holes.add(holeInput)
    
    faceNo = 1
    createHole(root.allOccurrences.item(0), faceNo, 0)
    createHole(root.allOccurrences.item(1), faceNo, 2)
    createHole(root.allOccurrences.item(2), faceNo, 0)
    createHole(root.allOccurrences.item(3), faceNo, 2)
   
  except:
    if ui:
      ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

Bug 1: After running the script you should find each component (plus copy, mirror and mirror copy) have two hole features added.  The holes that are created in the nativeObject appear correctly.  The holes in the copies are NOT.  Until, that is, you edit the hole in the timeline.  These holes appear in the right place and in the right occurrence, However, once the edit dialog box is closed the hole appears on the model, correctly formed. 

 

Bug 2: If you then open the dialog again, the hole being edited is now on the nativeObject - I strongly believe this is wrong - if you create a feature in an occurrence, it should definitely copy itself to the nativeObject, but its assemblyContext should remain with the occurrence and not change.

 

Bug3: If line 27 (holeInput.creationOccurrence = occurrence) is commented out, the hole appears on both the nativeObjects and the copies.  If keeping track of the assemblyContext was not the design intention then holeInput.creationOccurrence along with sister features such as sketches (

component.sketches.add(face, occurrence)) are broken.

 

Bug 4:  using component.sketches.add(face, occurrence)) (line 18) should have resulted in the sketch remaining in the occurrence context it was created in - similar to as described in Bug 3.  It reverts back to the nativeObject!

 

Bug 5: if you look at the hole dialog box that is created by the API - the placement icons are missing!!  (a minor bug, but indicative of something not quite right with the API)

 

In several documents, for example here at the AD university presentation by Brian Ekins, it's implied that an Occurrence takes care of the positional and rotational relationship of an occurrence to the rootComponent.  There's no evidence to show that the F360 implementation has actually followed that philiosophy - it would be wonderful if it did.  

 

In the same vein - it is totally bizarre to me to mix coordinate systems.  Anytime an Occurrence is referenced in the API, all coordinate systems should be consistent - for instance: 

holeFeatureInput_var.setPositionByPlaneAndOffsets(planarEntity, point, edgeOne, offsetOne, edgeTwo, offsetTwo)

"point" here is related to the NativeObject and its coordinates, whereas edgeOne and edgeTwo relate to the same coordinate system as the planarEntity (which is usually in an occurrence context).  Why are they different? - it goes to show that something is amiss in the implementation philosophy.  It's also unnecessarily confusing and complicated. 

 

Regards

Peter

 

  

 

 

 

 

I'm not an expert, but I know enough to be very, very dangerous.

Life long R&D Engineer (retired after 30+ years in Military Communications, Aerospace Robotics and Transport Automation).
3,179 Views
13 Replies
Replies (13)
Message 2 of 14

pludikar
Collaborator
Collaborator

Anybody out there!??

 

How do I get these bugs acknowledged and dealt with?

 

I have yet another bug of the same class to report: - this now makes 5, add the bugs I reported that you already fixed and we're at 8 or 9!

 

 

 

 

Along with the other reported bugs, this shows that internal handling of Occurrence is broken!  It is clear that .assemblyContext and .createForAssemblyContext attributes, not only in the API, but also in F360, bear little relationship to, what is intuitively, the original concept.

 

I see this as a significant failing of F360 - rather than adding new features, it would be better to spend effort in fixing the underlying technology.

I'm not an expert, but I know enough to be very, very dangerous.

Life long R&D Engineer (retired after 30+ years in Military Communications, Aerospace Robotics and Transport Automation).
0 Likes
Message 3 of 14

pludikar
Collaborator
Collaborator

In case you are wondering why I'm trying to make a fuss - it's because my workflow, which is typical of anyone making cabinets or assembly where the components gets nested, cannot work without totally unnecessary work arounds.

 

When you make a hole, or feature in a copy of a component, that hole should be related to the component copy (Occurrence), and not the Component (NativeObject).  The API and underlying F360 code has tried to accommodate this, but it hasn't been implemented (or it's a huge bug).

 

In the screencast below - I've isolated the components I'm going to nest and throw into CAM - at this stage I don't need the assembled model, but I will always need to refer to it, if I make changes at the nesting phase.  Why should I have to go to the original nativeObject location if I want to edit a feature - doesn't make sense.

 

 

 

I'm happy to discuss this offline

 

Regards

Peter

I'm not an expert, but I know enough to be very, very dangerous.

Life long R&D Engineer (retired after 30+ years in Military Communications, Aerospace Robotics and Transport Automation).
Message 4 of 14

goyals
Autodesk
Autodesk

Hi @pludikar,

 

Thank you for reporting these issues. I will look in to this and get back to you.

 

Regards,

Shyam Goyal



Shyam Goyal
Sr. Software Dev. Manager
0 Likes
Message 5 of 14

goyals
Autodesk
Autodesk

Hi @pludikar

 

I looked at your last recorded screencast. There are two types of paste options in Fusion 1. Paste 2. Paste New. In case of Paste, we are just creating an another instance of the same component/body so underlying geometry is same so if you are modifying any instance, all instances would be effected. I  think only few overrides like position, visibility etc can be applied on individual instance. 'Paste New' is like a deep copy. If you add feature on the copied component after paste new, changes won't be reflected back to original component.

 

I am still investigating the other issues you mentioned but feel free to revert back in case I did not understand the problem accurately.

 

Regards,

Shyam Goyal



Shyam Goyal
Sr. Software Dev. Manager
0 Likes
Message 6 of 14

goyals
Autodesk
Autodesk

Hi @pludikar

 

If possible Can you help me understand where API is working differently from Fusion UI in context of occurrence? It will help me to see if it is something wrong with API specifically or Fusion in general. I think occurrence in API is more implemented like Paste option in Fusion UI and not as paste new so if you are modifying the underlying geometry, the changes I propagated at every place. We can apply different attributes on each occurrence like transform, appearance, visibility and name etc. 

 

Regards,

Shyam Goyal



Shyam Goyal
Sr. Software Dev. Manager
0 Likes
Message 7 of 14

pludikar
Collaborator
Collaborator

Hi @goyals

 

I am totally familiar with the difference between Paste and Paste New.  I am using Paste deliberately - The screencast and my code snippets are CORRECT, and trying to do exactly what I want, except that F360 has bugs stopping it!

 

It is critical in this workflow that the assembled model, and the parts that are being nested, are identical.  Changes made in the laid out nested parts MUST be reflected in the assembled model, and vice versa.  This workflow is typical for anyone making an assembly of parts that are also laid out  for nesting.  I'd suggest you talk to @prainsberry (AD Business Development Manager) about how parts, particularly those in cabinet making, are laid flat prior to CAM.  Have a look at the 1st 20 seconds of his youtube video (here) to see an example of components that are nested (flattened out) ready for machining.

 

Regards

Peter

 

 

I'm not an expert, but I know enough to be very, very dangerous.

Life long R&D Engineer (retired after 30+ years in Military Communications, Aerospace Robotics and Transport Automation).
0 Likes
Message 8 of 14

pludikar
Collaborator
Collaborator

Hi @goyals,

 

Here's another example of nesting in Fusion - also by Patrick Rainsberry.  The difference is I want to keep the original assembly - so I make a copy (not a paste new!!) and operate on the copy.

 

Peter

I'm not an expert, but I know enough to be very, very dangerous.

Life long R&D Engineer (retired after 30+ years in Military Communications, Aerospace Robotics and Transport Automation).
0 Likes
Message 9 of 14

pludikar
Collaborator
Collaborator

Hi @goyals,

 

I'm assuming that you have run the code I included in my original report in this thread (along with the model).  If you haven't, it should answer most of the questions you posed. 

 

If you did, you will find Line 27 is the culprit.  ( holeInput.creationOccurrence = occurrence).  It attempts to behave as I would expect - it attempts to place a hole in the context of the specified occurrence (including calling up the the correct Occurrence for the timeline edit!), while still modifying the nativeObject geometry.  This would be very logical and intuitive.  However - it throws an error!!

 

If you are saying that it doesn't do this in the normal UI, and you are saying that it shouldn't be doing this - then what is the point of including holeInput.creationOccurrence (plus Sketch.createForAssemblyContext, BRepBody.createForAssemblyContext, HoleFeature.createForAssemblyContext... the list goes on)?

 

Regards

Peter

 

I'm not an expert, but I know enough to be very, very dangerous.

Life long R&D Engineer (retired after 30+ years in Military Communications, Aerospace Robotics and Transport Automation).
0 Likes
Message 10 of 14

goyals
Autodesk
Autodesk

Hi @pludikar,

 

I run your script and able to reproduce all issues. I am not able to understand bug 5 but anway it looks like of low priority. A  ticket is already created to track these issues. I will update you once I got all the issues fixed.

 

Regards,

Shyam Goyal



Shyam Goyal
Sr. Software Dev. Manager
0 Likes
Message 11 of 14

goyals
Autodesk
Autodesk

Hi @pludikar

 

These are the rules for how to specify the occurrence to create an object.

 

When using the API to create an object using reference geometry, the API client needs to specify the parameters carefully and he may need to supply a creation Occurrence. The rules depend on the Component in which the reference geometry (or geometries) and the created object live (or will live, after creation). 

  1. If the created object and the reference geometry are in the root component, then a creation Occurrence is not specified and the referenced geometry is specified via the Native Object.
  2. If the created object and the reference geometry (or geometries) are in the same (non-root) component, then a creation Occurrence is not specified and the referenced geometry can be specified either via the Native Object or via an Assembly Context.
  3. If the created object and the reference geometry (or geometries) are in different components, then a creation Occurrence must be specified if the created object is not in the root component. The referenced geometry must be specified via an Assembly Context if it is not in the root component.

In the script you shared it not required to specify the occurrence as per rule 2 hence it works as expected if you comment out that line no. 27.

 

In Fusion UI as well If we try to edit a feature on an occurrence then it shows the edit dialog on original component hence it looks like as designed for now but I acknowledge your point and ideally it should display the edit dialog on feature in occurrence but Fusion in general does not support edit-in-context as per my knowledge.

 

Regards,

Shyam Goyal



Shyam Goyal
Sr. Software Dev. Manager
0 Likes
Message 12 of 14

pludikar
Collaborator
Collaborator

@goyals

 

Unfortunately your explanation makes no sense to me - it look like what you are saying is if you want to use holeInput.creationOccurrence you have to comment it out?!!  

 

I've been coding Fusion API for the past year and am fully familiar with the unnecessarily confusing and contorted API, particularly when it comes to Occurrences.  I know that you've seen the code I've produced for dogbones- over a 1000 LOC doesn't happen overnight.

 

On line 24, the holesFeature variable is created in the context of the Component or nativeObject.  Similarly the participantBodies  are also created in the context of the component or nativeObject.  So, by your argument I've already met the conditions of rule 2.

 

If I'm wrong, please give me a working example of using holeInput.creationOccurrence = occurrence.  Maybe modify my code to show what needs to be done - it will be helpful to anyone who tries to use your API.

 

Regards

Peter

 

 

I'm not an expert, but I know enough to be very, very dangerous.

Life long R&D Engineer (retired after 30+ years in Military Communications, Aerospace Robotics and Transport Automation).
Message 13 of 14

Anonymous
Not applicable

Hey Autodesk! How are the bugfixes progressing? F360 users with CNC routers would appreciate an ability to have fully parameterized dogbones generated from https://github.com/DVE2000/Dogbone so they can change the cutter size more easily. Looks like these bugs are blocking a reliable implementation.

Message 14 of 14

Anonymous
Not applicable

I did some digging and there is another dogbone extension that seem to be suffering from similar problems. They have worked around that by adding an "update dogbones" feature to their offering and the narration in the video mentions that they hope this can be automatic in the future.

 

https://apps.autodesk.com/FUSION/en/Detail/Index?id=3534533763590670806&appLang=en&os=Win64

 

This is an indication that the problems are real and not simply caused by one developer misunderstanding Fusion API.

Nobody knows how many other extensions are either sub-optimal or were never finished because of these shortcomings. For the health of the plugins ecosystem, please prioritize the necessary fixes.