Author Topic: PartStatus Set  (Read 432 times)

0 Members and 1 Guest are viewing this topic.

Offline AN-detailTopic starter

  • Active Member
  • **
  • Posts: 7
  • Country: us
  • Gender: Male
PartStatus Set
« on: Oct 24, 2024, 19:26:31 PM »
According to the Revit API docs, FabricationPart.PartStatus is read/write (get set).

When I set it in my script, I can get a return of my new value, but it reverts back after the script moves on to the next element.

I am setting it with element.PartStatus = myinteger
Am I missing something?


Offline dopefish

  • Senior Member
  • ****
  • Posts: 458
  • Country: us
  • Gender: Male
Re: PartStatus Set
« Reply #1 on: Oct 28, 2024, 13:19:14 PM »
That you Adam?

And is there a transaction commit that is missing?
"And the wood header is still 4  3/4" on top of the top of the double top plate." . . . Random VDC Coodinator

I love coordination

Offline AN-detailTopic starter

  • Active Member
  • **
  • Posts: 7
  • Country: us
  • Gender: Male
Re: PartStatus Set
« Reply #2 on: Oct 30, 2024, 18:09:50 PM »
Yeah, check your private messages.

So the issue appears to be this: when I set the PartStatus using my script, it returns correctly. Checking the value again afterwards with another debugging script, it retains the value & returns correctly. Then, if I modify the part at all, such as stretching it or adding a value to a parameter in the properties panel, the PartStatus reverts back to the default, which is 0 in our config.

If I use Evolve's 'Export MAJ' button and set the status using that tool, the status does not change after modifying the part, it retains the value.

Not sure what causes this. Here's the python script I'm running thru pyrevit, without the imports:

Code: [Select]
# Get the currently selected elements in the document
selection = uidoc.Selection.GetElementIds()

if selection:

    # PartStatus index number
    input_int = 1

    # Start a new transaction in the Revit document
    t = Transaction(doc, "Set PartStatus")
    t.Start()

    # Iterate through the selected elements
    for element_id in selection:
        # Get the element from the document using its ID
        element = doc.GetElement(element_id)
        # Check if the selected element is a FabricationPart
        if isinstance(element, FabricationPart):
           
            # Return current PartStatus
            print(element.PartStatus)
           
            # Set new PartStatus
            element.PartStatus = input_int
           
            # Return new PartStatus
            print(element.PartStatus)
   
    # Commit the transaction to apply the changes
    t.Commit()

Offline dopefish

  • Senior Member
  • ****
  • Posts: 458
  • Country: us
  • Gender: Male
Re: PartStatus Set
« Reply #3 on: Nov 19, 2024, 15:15:35 PM »
It sounds like it might be reloading the item from disk when you are modifying it. Maybe change the default status of that part in your DB to some other number and then run your script and modify and see if it reverts back to that now instead of 0. Your script may be working perfectly and revit itself is the culprit.
"And the wood header is still 4  3/4" on top of the top of the double top plate." . . . Random VDC Coodinator

I love coordination

Offline AN-detailTopic starter

  • Active Member
  • **
  • Posts: 7
  • Country: us
  • Gender: Male
Re: PartStatus Set
« Reply #4 on: Nov 26, 2024, 21:58:37 PM »
I'm 90% sure the issue is caused by a conflict with Evolve, which is resetting Status and any Custom Data that I set thru my script back to the ITM's default values.

On a instance of vanilla Revit without Evolve installed, this problem did not occur.