how it be in Visual Basic
how it be in Visual Basic
(OP)
could anyone to help
I know in GRIP but in VB :(
how to work with drawing objects
i need just to check colors of object
if color number is wrong, prompt the user...
where is mistake
error:"Number of indices is less than the number of dimensions of the indexed array" in line with "askdisplayedobjects"
code:
Sub check_colors
Dim theSession As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim workPart As Part = theSession.Parts.Work
Dim drawingSheets() As DrawingSheet
Dim mySheet as DrawingSheet
drawingSheets = workPart.DrawingSheets.toArray
Dim dfviews() As DraftingView
Dim dfview As DraftingView
Dim num_objects As Integer
Dim objects() As Tag
For Each mySheet In drawingSheets
dfviews = mySheet.GetDraftingViews()
For Each dfview In dfviews
ufs.Draw.AskDisplayedObjects( dfview.tag,num_objects , objects())
Next
Next
End sub
I know in GRIP but in VB :(
how to work with drawing objects
i need just to check colors of object
if color number is wrong, prompt the user...
where is mistake
error:"Number of indices is less than the number of dimensions of the indexed array" in line with "askdisplayedobjects"
code:
Sub check_colors
Dim theSession As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim workPart As Part = theSession.Parts.Work
Dim drawingSheets() As DrawingSheet
Dim mySheet as DrawingSheet
drawingSheets = workPart.DrawingSheets.toArray
Dim dfviews() As DraftingView
Dim dfview As DraftingView
Dim num_objects As Integer
Dim objects() As Tag
For Each mySheet In drawingSheets
dfviews = mySheet.GetDraftingViews()
For Each dfview In dfviews
ufs.Draw.AskDisplayedObjects( dfview.tag,num_objects , objects())
Next
Next
End sub





RE: how it be in Visual Basic
I think it needs to be :
ufs.Draw.AskDisplayedObjects( dfview.tag,num_objects , objects)
or possibly you need to have an integer counting through the dfviews and specify a sinlge item in the array
dim my_int as integer = 0
For Each mySheet In drawingSheets
dfviews = mySheet.GetDraftingViews()
For Each dfview In dfviews
ufs.Draw.AskDisplayedObjects(dfview.tag,num_objects , objects(my_int))
my_int = my_int + 1
Next
Next
Mark Benson
Aerodynamic Model Designer
RE: how it be in Visual Basic
in first case
[ufs.Draw.AskDisplayedObjects( dfview.tag,num_objects , objects)]
Runtime error:
NXOpen.NXException: Input tag is not a section view.
at NXOpen.UF.UFDraw.AskDisplayedObjects(Tag view, Int32& num_objects, Tag[]& objects)
in second
[ufs.Draw.AskDisplayedObjects(dfview.tag,num_objects , objects(my_int))]
Syntax errors:
Value of type 'NXOpen.Tag' cannot be converted to '1-dimensional array of NXOpen.Tag'.
RE: how it be in Visual Basic
You have another problem.
As the error tells you the tag is not correct for what you are trying to do.
The tag you are obtaining is the tag of the view not the objects in it.
You need to have a look at the mebers of drawingview to see if there is any way of listing the objects in the view and obtaining their tags.
Mark Benson
Aerodynamic Model Designer