Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Worksets Node #2093

Closed
MaxSpex opened this Issue Jul 16, 2018 · 8 comments

Comments

Projects
None yet
5 participants
@MaxSpex
Copy link

MaxSpex commented Jul 16, 2018

If this issue is not a bug report or improvement request, please check the Dynamo forum, and start a thread there to discuss your issue.

Dynamo version

2.0.1.5065

Revit version

2018

Operating system

Windows 7

What did you do?

Every time i run graph with Worksets node, node duplicates its output.

What did you expect to see?

Node not to change number of its outputs

What did you see instead?

Duplicating outputs, previous output becomes invalid
capture

@johnpierson

This comment has been minimized.

Copy link
Collaborator

johnpierson commented Jul 17, 2018

@MaxSpex This is a custom node from the custom package archilab. You might want to reach out to @ksobon directly regarding the compatibility with Dynamo 2.0.x

@ksobon

This comment has been minimized.

Copy link
Contributor

ksobon commented Aug 18, 2018

@mjkkirschner is there a reason why this code:

[NodeName("Worksets")]
    [NodeCategory("archilab.Revit.Workset")]
    [NodeDescription("Retrieve all available Worksets.")]
    [IsDesignScriptCompatible]
    public class WorksetUi : RevitDropDownBase
    {
        private const string OutputName = "workset";
        private const string NoFamilyTypes = "No types were found.";

        public WorksetUi() : base(OutputName) { }

        [JsonConstructor]
        public WorksetUi(IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPorts) : base(OutputName, inPorts, outPorts) { }

        protected override SelectionState PopulateItemsCore(string currentSelection)
        {
            Items.Clear();

            var allWorksets = new Autodesk.Revit.DB.FilteredWorksetCollector(DocumentManager.Instance.CurrentDBDocument)
                .OfKind(Autodesk.Revit.DB.WorksetKind.UserWorkset)
                .ToList();

            if (allWorksets.Count == 0)
            {
                Items.Add(new DynamoDropDownItem(NoFamilyTypes, null));
                SelectedIndex = 0;
                return SelectionState.Done;
            }

            foreach (var w in allWorksets)
            {
                Items.Add(new DynamoDropDownItem(w.Name, w));
            }
            Items = Items.OrderBy(x => x.Name).ToObservableCollection();
            return SelectionState.Restore;
        }

        public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode> inputAstNodes)
        {
            AssociativeNode node;

            if (SelectedIndex == -1)
            {
                node = AstFactory.BuildNullNode();
            }
            else
            {
                var workset = Items[SelectedIndex].Item as Autodesk.Revit.DB.Workset;
                if (workset == null)
                {
                    node = AstFactory.BuildNullNode();
                }
                else
                {
                    var idNode = AstFactory.BuildIntNode(workset.Id.IntegerValue);
                    node = AstFactory.BuildFunctionCall(
                        new Func<int, Workset>(archilab.Utilities.ElementSelector.GetWorksetById),
                        new List<AssociativeNode> { idNode });
                }
            }

            return new[] { AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), node) };
        }
    }

results in an issue with duplicate ports as above? I don't see how that is any different from the code that you guys use in DynamoRevit. For example I placed FamilyTypes node on canvas mext to my node. Saved the file, and when opened it looks like this:

image

I looked at the JSON file that was serialized when the two workspace was saved, and its exactly the same for Worksets as it is for Family Types nodes.

{
      "ConcreteType": "DSRevitNodesUI.FamilyTypes, DSRevitNodesUI",
      "SelectedIndex": 1,
      "NodeType": "ExtensionNode",
      "Id": "25bc3ddbd98d4e87aea1116d62287757",
      "Inputs": [],
      "Outputs": [
        {
          "Id": "7ff204ee9c1844ce862708275854ed32",
          "Name": "Family Type",
          "Description": "The selected Family Type",
          "UsingDefaultValue": false,
          "Level": 2,
          "UseLevels": false,
          "KeepListStructure": false
        }
      ],
      "Replication": "Disabled",
      "Description": "All family types available in the document."
    },
{
      "ConcreteType": "archilabUI.WorksetUi, archilabUI",
      "SelectedIndex": 1,
      "NodeType": "ExtensionNode",
      "Id": "10bc28578aee47e18a781d13f0979a2a",
      "Inputs": [],
      "Outputs": [
        {
          "Id": "31171e964fd54085b5c56fe3032456e4",
          "Name": "workset",
          "Description": "The selected workset",
          "UsingDefaultValue": false,
          "Level": 2,
          "UseLevels": false,
          "KeepListStructure": false
        }
      ],
      "Replication": "Disabled",
      "Description": "Retrieve all available Worksets."
    },

What's going on here?

@ksobon

This comment has been minimized.

Copy link
Contributor

ksobon commented Aug 27, 2018

@mjkkirschner hey do you mind helping me out with this? People want their 2.0 update and it's not happening...

@mjkkirschner

This comment has been minimized.

Copy link
Member

mjkkirschner commented Aug 27, 2018

Hey @ksobon I will find some time tonight to look at it.

@mjkkirschner

This comment has been minimized.

Copy link
Member

mjkkirschner commented Aug 27, 2018

Hey @ksobon I was about to build your repo and I noticed that you reference json.net 11.0 - I would change this to reference the same version revit and dynamo use- I believe this is 8.03. I think as far as your code is concerned, everything is fine, and no changes will be required, only a recompile.

I think that because we use attributes to mark the constructors to use during deserialization these are not identified by the .net runtime as the same attribute and so your jsonConstructor is not used.

IE - the 8.03 version of [JsonConstructor] is not the same as the version 11 [JsonConstructor] - json.net picks the constructor to use by finding matching attributes, so I think sticking to the same version will help.

I'll have to think on how to make this more robust in the future. Please let me know if that fixes the issue. If not I will build your repo and debug.

@ksobon

This comment has been minimized.

Copy link
Contributor

ksobon commented Aug 27, 2018

@mjkkirschner of course you are right. I didn't realize that I was using a newer version. It seems to be working fine now. Thanks!

@MaxSpex here's a PR that will resolve the issue: ksobon/archilab#20 I got some more things to look at for a full update but it should be ready tomorrow.

@johnpierson

This comment has been minimized.

Copy link
Collaborator

johnpierson commented Aug 30, 2018

Cool stuff here. Using some of the comments on this thread I have managed to get Rhythm working properly as well!

@ksobon

This comment has been minimized.

Copy link
Contributor

ksobon commented Sep 12, 2018

@kronz this update was finally released. thank you for your support with issues that I have had with the package. Can we close this issue?
@MaxSpex you can download latest version of archi-lab from Pacakge Manager. This was fixed in version 2019.2.0.

@kronz kronz closed this Sep 15, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.