简体   繁体   English

使用多个项目参数从Excel创建Revit工作表

[英]Create Revit Sheets from Excel with multiple project parameters

Hi I have a macro that creates multiple sheets and has Name, Number, Sheet Category. 嗨,我有一个宏,可以创建多个工作表,并具有名称,编号,工作表类别。 The last being my own project parameter. 最后一个是我自己的项目参数。

I can successfully create the sheets with name and number but I am having difficulty adding the value from CSV file to the project parameter "SD_Sheet Category". 我可以成功创建带有名称和编号的图纸,但是我很难将CSV文件中的值添加到项目参数“ SD_Sheet类别”中。 Below are some code grabs to help explain. 以下是一些代码片段以帮助解释。

Public Module mSheetCreator
Public Structure structSheet
    Public sheetNum As String
    Public sheetName As String
    Public sortCategory As String
End Structure

Then I have a function that reads the CSV file and does the following: 然后,我有一个读取CSV文件并执行以下操作的函数:

            Try
                currentRow = MyReader.ReadFields()

                'create temp sheet
                Dim curSheet As New structSheet
                curSheet.sheetNum = currentRow(0)
                cursheet.sheetName = currentRow(1)
                curSheet.sortCategory = currentRow(4)

                'add sheet to list
                sheetList.Add(curSheet)

Then I have a transaction that does the following: 然后,我有一个执行以下操作的事务:

For Each curSheet As structSheet In sheetList
        Try
        If sheetType = "Placeholder Sheet" Then
m_vs = ViewSheet.CreatePlaceholder(curDoc)
        Else 
m_vs = ViewSheet.Create(curDoc, tblock.Id)
m_vs.Parameter("SD_Sheet Category").Set(CStr(curSheet.sortCategory))
        End If
m_vs.Name = curSheet.sheetName
m_vs.SheetNumber = curSheet.sheetNum

The problem is this code: 问题是此代码:

m_vs.Parameter("SD_Sheet Category").Set(CStr(curSheet.sortCategory))

I am getting a warning that says it's an "implicit conversion from 'String' to 'Autodesk.Revit.DB.BuiltInParameter'" once I build solution 生成解决方案后,我收到一条警告,说这是“从'字符串'到'Autodesk.Revit.DB.BuiltInParameter'的隐式转换”

When I run the code in Revit it produces an error saying 当我在Revit中运行代码时,会产生一条错误消息

"Conversion from string 'SD_Sheet Category" to type 'Integer' is not valid" “从字符串“ SD_Sheet类别”到类型“整数”的转换无效”

It creates the sheets but disregards all the info in the CSV file. 它会创建工作表,但会忽略CSV文件中的所有信息。 I know the rest of the code works as I have removed this particular line of code so I know it isn't the problem 我知道其余代码可以正常工作,因为我已经删除了这一行代码,所以我知道这不是问题

Any suggestions?? 有什么建议么??

I believe that as of a particular version of Revit API you cannot use .Parameter(“name”) 我认为,从特定版本的Revit API开始,您不能使用.Parameter(“ name”)

Because there might be two parameters with the same name. 因为可能有两个参数具有相同的名称。

So you need to do something more like 所以你需要做更多类似的事情

Dim cat as Parameter

Cat = m_vs.GetParameters(“sd_sheet category”).First() Cat.Set(CSTR(cursht.sortCategory)) Cat = m_vs.GetParameters(“ sd_sheet类别”).First()Cat.Set(CSTR(cursht.sortCategory))

Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM