Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Revit API

4 REPLIES 4
Reply
Message 1 of 5
Anonymous
727 Views, 4 Replies

Revit API

Anonymous
Not applicable

Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports Autodesk.Revit.ApplicationServices
Imports Autodesk.Revit.Attributes

Imports Autodesk.Revit.DB
Imports Autodesk.Revit.DB.Events
Imports Autodesk.Revit.DB.Architecture
Imports Autodesk.Revit.DB.Structure
Imports Autodesk.Revit.DB.Mechanical
Imports Autodesk.Revit.DB.Electrical
Imports Autodesk.Revit.DB.Plumbing

Imports Autodesk.Revit.UI
Imports Autodesk.Revit.UI.Selection
Imports Autodesk.Revit.UI.Events


Imports Autodesk.Revit.Exceptions
Imports Autodesk.Revit.Utility

Imports RvtApplication = Autodesk.Revit.ApplicationServices.Application
Imports RvtDocument = Autodesk.Revit.DB.Document

 

Public Function Execute(ByVal commandData As ExternalCommandData, ByVal message As ref, ByVal elements As ElementSet) As CmdResult

 

i have problem here , Please can you tell me what is the problem.

Statment is not valid in the Namespace.

Thanks

 


Dim app As Application = commandData.Application
Dim doc As Document = app.ActiveDocument

Dim e As New Element()
Dim num As Integer = 1
Dim it As ElementIterator = doc.Elements
Do While it.MoveNext()
e = it.Current [as] Element
Try
' get the BuiltInParameter.ALL_MODEL_MARK paremeter.
' If the element does not have this paremeter,
' get_Parameter method returns null:

Dim p As Parameter = e.get_Parameter(BuiltInParameter.ALL_MODEL_MARK)

If p IsNot Nothing Then
' we found an element with the
' BuiltInParameter.ALL_MODEL_MARK
' parameter. Change the value and
' increment our value:

p.Set(num.ToString())
num += 1
End If
Catch ex As Exception
Util.ErrorMsg("Exception: " & ex.Message)
End Try
Loop
doc.EndTransaction()
Return CmdResult.Succeeded
End Function

0 Likes

Revit API

Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports Autodesk.Revit.ApplicationServices
Imports Autodesk.Revit.Attributes

Imports Autodesk.Revit.DB
Imports Autodesk.Revit.DB.Events
Imports Autodesk.Revit.DB.Architecture
Imports Autodesk.Revit.DB.Structure
Imports Autodesk.Revit.DB.Mechanical
Imports Autodesk.Revit.DB.Electrical
Imports Autodesk.Revit.DB.Plumbing

Imports Autodesk.Revit.UI
Imports Autodesk.Revit.UI.Selection
Imports Autodesk.Revit.UI.Events


Imports Autodesk.Revit.Exceptions
Imports Autodesk.Revit.Utility

Imports RvtApplication = Autodesk.Revit.ApplicationServices.Application
Imports RvtDocument = Autodesk.Revit.DB.Document

 

Public Function Execute(ByVal commandData As ExternalCommandData, ByVal message As ref, ByVal elements As ElementSet) As CmdResult

 

i have problem here , Please can you tell me what is the problem.

Statment is not valid in the Namespace.

Thanks

 


Dim app As Application = commandData.Application
Dim doc As Document = app.ActiveDocument

Dim e As New Element()
Dim num As Integer = 1
Dim it As ElementIterator = doc.Elements
Do While it.MoveNext()
e = it.Current [as] Element
Try
' get the BuiltInParameter.ALL_MODEL_MARK paremeter.
' If the element does not have this paremeter,
' get_Parameter method returns null:

Dim p As Parameter = e.get_Parameter(BuiltInParameter.ALL_MODEL_MARK)

If p IsNot Nothing Then
' we found an element with the
' BuiltInParameter.ALL_MODEL_MARK
' parameter. Change the value and
' increment our value:

p.Set(num.ToString())
num += 1
End If
Catch ex As Exception
Util.ErrorMsg("Exception: " & ex.Message)
End Try
Loop
doc.EndTransaction()
Return CmdResult.Succeeded
End Function

4 REPLIES 4
Message 2 of 5
mhillis
in reply to: Anonymous

mhillis
Advocate
Advocate

The code you posted does not have a namespace.

 

 

Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports Autodesk.Revit.ApplicationServices
Imports Autodesk.Revit.Attributes
Imports Autodesk.Revit.DB
Imports Autodesk.Revit.DB.Events
Imports Autodesk.Revit.DB.Architecture
Imports Autodesk.Revit.DB.Structure
Imports Autodesk.Revit.DB.Mechanical
Imports Autodesk.Revit.DB.Electrical
Imports Autodesk.Revit.DB.Plumbing
Imports Autodesk.Revit.UI
Imports Autodesk.Revit.UI.Selection
Imports Autodesk.Revit.UI.Events

Imports Autodesk.Revit.Exceptions
Imports Autodesk.Revit.Utility
Imports RvtApplication = Autodesk.Revit.ApplicationServices.Application
Imports RvtDocument = Autodesk.Revit.DB.Document

Namespace YourProject
   Public Function Execute(ByVal commandData As ExternalCommandData,    ByVal message As ref, ByVal elements As ElementSet) As CmdResult
      'your code goes here.
   End Function
End Namespace

 

 

0 Likes

The code you posted does not have a namespace.

 

 

Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports Autodesk.Revit.ApplicationServices
Imports Autodesk.Revit.Attributes
Imports Autodesk.Revit.DB
Imports Autodesk.Revit.DB.Events
Imports Autodesk.Revit.DB.Architecture
Imports Autodesk.Revit.DB.Structure
Imports Autodesk.Revit.DB.Mechanical
Imports Autodesk.Revit.DB.Electrical
Imports Autodesk.Revit.DB.Plumbing
Imports Autodesk.Revit.UI
Imports Autodesk.Revit.UI.Selection
Imports Autodesk.Revit.UI.Events

Imports Autodesk.Revit.Exceptions
Imports Autodesk.Revit.Utility
Imports RvtApplication = Autodesk.Revit.ApplicationServices.Application
Imports RvtDocument = Autodesk.Revit.DB.Document

Namespace YourProject
   Public Function Execute(ByVal commandData As ExternalCommandData,    ByVal message As ref, ByVal elements As ElementSet) As CmdResult
      'your code goes here.
   End Function
End Namespace

 

 

Message 3 of 5
Anonymous
in reply to: mhillis

Anonymous
Not applicable

i added the namespace even but than even it does not work.

 

 

Imports Autodesk.Revit.ApplicationServices

Imports Autodesk.Revit.Attributes

Imports Autodesk.Revit.DB
Imports Autodesk.Revit.DB.Events
Imports Autodesk.Revit.DB.Architecture
Imports Autodesk.Revit.DB.Structure
Imports Autodesk.Revit.DB.Mechanical
Imports Autodesk.Revit.DB.Electrical
Imports Autodesk.Revit.DB.Plumbing

Imports Autodesk.Revit.UI
Imports Autodesk.Revit.UI.Selection
Imports Autodesk.Revit.UI.Events


Imports Autodesk.Revit.Exceptions
Imports Autodesk.Revit.Utility

Imports RvtApplication = Autodesk.Revit.ApplicationServices.Application
Imports RvtDocument = Autodesk.Revit.DB.Document
Namespace Removal

 

Public Function Execute(ByVal commandData As ExternalCommandData, ByVal message As ref, ByVal elements As ElementSet) As CmdResult
Dim app As Application = commandData.Application
Dim doc As Document = app.ActiveDocument

 

Dim e As New Element()

Dim num As Integer = 1
Dim it As ElementIterator = doc.Elements
Do While it.MoveNext()
e = it.Current [as] Element
Try
' get the BuiltInParameter.ALL_MODEL_MARK paremeter.
' If the element does not have this paremeter,
' get_Parameter method returns null:

Dim p As Parameter = e.get_Parameter(BuiltInParameter.ALL_MODEL_MARK)

If p IsNot Nothing Then
' we found an element with the
' BuiltInParameter.ALL_MODEL_MARK
' parameter. Change the value and
' increment our value:

p.Set(num.ToString())
num += 1
End If
Catch ex As Exception
Util.ErrorMsg("Exception: " & ex.Message)
End Try
Loop
doc.EndTransaction()
Return CmdResult.Succeeded
En()
End Function
End Namespace

 

0 Likes

i added the namespace even but than even it does not work.

 

 

Imports Autodesk.Revit.ApplicationServices

Imports Autodesk.Revit.Attributes

Imports Autodesk.Revit.DB
Imports Autodesk.Revit.DB.Events
Imports Autodesk.Revit.DB.Architecture
Imports Autodesk.Revit.DB.Structure
Imports Autodesk.Revit.DB.Mechanical
Imports Autodesk.Revit.DB.Electrical
Imports Autodesk.Revit.DB.Plumbing

Imports Autodesk.Revit.UI
Imports Autodesk.Revit.UI.Selection
Imports Autodesk.Revit.UI.Events


Imports Autodesk.Revit.Exceptions
Imports Autodesk.Revit.Utility

Imports RvtApplication = Autodesk.Revit.ApplicationServices.Application
Imports RvtDocument = Autodesk.Revit.DB.Document
Namespace Removal

 

Public Function Execute(ByVal commandData As ExternalCommandData, ByVal message As ref, ByVal elements As ElementSet) As CmdResult
Dim app As Application = commandData.Application
Dim doc As Document = app.ActiveDocument

 

Dim e As New Element()

Dim num As Integer = 1
Dim it As ElementIterator = doc.Elements
Do While it.MoveNext()
e = it.Current [as] Element
Try
' get the BuiltInParameter.ALL_MODEL_MARK paremeter.
' If the element does not have this paremeter,
' get_Parameter method returns null:

Dim p As Parameter = e.get_Parameter(BuiltInParameter.ALL_MODEL_MARK)

If p IsNot Nothing Then
' we found an element with the
' BuiltInParameter.ALL_MODEL_MARK
' parameter. Change the value and
' increment our value:

p.Set(num.ToString())
num += 1
End If
Catch ex As Exception
Util.ErrorMsg("Exception: " & ex.Message)
End Try
Loop
doc.EndTransaction()
Return CmdResult.Succeeded
En()
End Function
End Namespace

 

Message 4 of 5
jeremytammik
in reply to: Anonymous

jeremytammik
Autodesk
Autodesk

Please work through the Revit API getting started material, especially the DevTV and My First Revit Plugin tutorials:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#2

 

Then all will become clear.

 

Have fun!

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes

Please work through the Revit API getting started material, especially the DevTV and My First Revit Plugin tutorials:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#2

 

Then all will become clear.

 

Have fun!

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 5 of 5
mehsan
in reply to: jeremytammik

mehsan
Advocate
Advocate

I am not so much experts in this still learning, but i need this API please can you correct and Send me, Thanks

0 Likes

I am not so much experts in this still learning, but i need this API please can you correct and Send me, Thanks

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report