Skip to content

DesignScript class keyword disabled in code blocks #8473

Description

@radumg

Dynamo version

1.2, 1.3, 2.0

Operating system

Windows 7, Windows 10

What did you do?

wrote a class definition in a code block, such as :

class MyPoint {
...
}

Also tried it with [InternalClass] and [InternalClassAttribute] attributes on the class.

However, saving that class definition to a whatever.ds file and loading that in through File > Import happily registers the class and enables it to be further used in DS code blocks.

Also tried

Disabled the line in Dynamo source code that checks for the class keyword in code blocks and halts evaluation and rebuilt project, still won't let me use it. Not sure what the issue is?

What did you expect to see?

Class definition to work.

What did you see instead?

Code block node reports classes are not supported in code block node.
classes
(in Dynamo 2.0, disregard actual class code which might be incorrect)

Activity

  1. aparajit-pratap commented on Jan 18, 2018

    @aparajit-pratap
    Contributor

    @radumg this is as-designed. DesignScript classes are intentionally disabled in code blocks. They have limited support in the language itself and are meant for internal use only. There are some user-facing features such as function objects that are built on top of DS classes. One of the ways users can exploit them is by writing DesignScript in ".ds" files and importing them into Dynamo using "File->Import Library" menu. The classes and methods should appear in the "AddOns" section of the library after import.

  2. radumg commented on Jan 18, 2018

    @radumg
    CollaboratorAuthor

    Thanks @aparajit-pratap, that is indeed what i'm having to do.
    My question is :

    • why are they intentionally disabled in code blocks (since they're allowed through .ds files, i assume it's not because the engine doesn't support them)
    • and is there scope at all for enabling them in code blocks?

    I'm finding the ability to define classes that extend ZT/C# classes in a dynamic way useful, especially when interacting with the web.

  3. aparajit-pratap commented on Jan 18, 2018

    @aparajit-pratap
    Contributor

    @radumg so you're defining DS classes that extend C# classes? If so, that's brilliant that you figured this out! This was enabled relatively recently but only for internal development purposes and not to be meant as a user-facing feature. It's amazing that you're using it that way. AFAIK classes were never enabled in CBN's for a very long time. @kronz may have more to add about these decisions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions