Error in ExternalDefinitionCreationOptions

Error in ExternalDefinitionCreationOptions

helsted
Contributor Contributor
1,411 Views
2 Replies
Message 1 of 3

Error in ExternalDefinitionCreationOptions

helsted
Contributor
Contributor

Hi

 

I'm trying to define a new instance of an ExternalDefinitionCreationOptions(string name, ForgeTypeId dataType):

 

string name = "Psi"
ForgeTypeId dataType = new ForgeTypeId("Number");

ExternalDefinitionCreationOptions options = new ExternalDefinitionCreationOptions(defName, dataType);

 

 

This works when I'm using the now-deprecated ParameterType.Number instead of ForgeTypeId. However, currently I'm getting this message:

Insert_properties_fejl_1.png

I have little experience with ForgeTypeId. Am I using the class wrong?

0 Likes
Accepted solutions (1)
1,412 Views
2 Replies
Replies (2)
Message 2 of 3

jeremy_tammik
Alumni
Alumni
Accepted solution

Look at the ForgeTypeId constructor documentation:

 

https://www.revitapidocs.com/2022/4777ba3d-8f1e-399c-8f3a-cca084b2d42b.htm

 

It constructs a ForgeTypeId holding the given schema identifier.
 
"Number" is not a valid  schema identifier. You can see a sample using ExternalDefinitionCreationOptions with a ForgeTypeId in The Building Coder samples CmdCreateSharedParams.cs:
 
 
Basically, it uses:
 
  ForgeTypeId _deftype = SpecTypeId.Number;
  var opt = new ExternalDefinitionCreationOptions( defname, _deftype);
  definition = group.Definitions.Create(opt);
  
 
 
Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 3 of 3

helsted
Contributor
Contributor

Hi Jeremy

 

Thank you very much - that worked perfectly!

 

Kind regards
Mathias

0 Likes