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

iLogic Problem. Display text & Number in a value

2 REPLIES 2
Reply
Message 1 of 3
shmartin89
636 Views, 2 Replies

iLogic Problem. Display text & Number in a value

Im linking a prompted entry in a sketch symbol to a selection from the user in an array.

 

The code works perfectly.

 

The array displays the number of sheets there are in the document, the user selects the correct one & the sheet number is displayed in the prompted entry.

 

I need to add "SHT" before the number though in the code but I cant get it to work.

 

Any Ideas?

 

I dont jwant to add a text line into the symbol saying "sht"

 

Thanks

 

Sandy

 

Code:

 

Dim oApp As Application: oApp = ThisApplication
Dim oDoc As DrawingDocument: oDoc = oApp.ActiveDocument
Dim oSheet As Sheet: oSheet = oDoc.ActiveSheet

'This uses a sketch symbol with the name "'View On' View Label"
Dim oSymDef As SketchedSymbolDefinition: oSymDef = oDoc.SketchedSymbolDefinitions.Item("'View On' View Label")

'This is the selected view
Dim oView As DrawingView: oView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter,"Select View To Place Symbol:")

'This takes the label items of the selected view
'And adds it To an array that will link To the prompted entry
Dim sPromptStrings(2) As String
sPromptStrings(0) = oView.Name
sPromptStrings(1) = oView.ScaleString

oDoc = ThisApplication.ActiveDocument

Dim sSheet As Sheet

'create sheet number list
Dim oSheetList As New ArrayList
i = 0
s = "-"
For Each sSheet In oDoc.Sheets
i = i +1
oSheetList.add(i)
Next
oSheetList.add(s)

'get user input
mySheet = (InputListBox("View taken form sheet number.", oSheetList, oSheetList(0), "Sheet Number Ref.", "Sheet Numbers"))

sPromptStrings(2) = mySheet

'This is the position for the sketched symbol under the selected view'
Dim oPosition As Point2d: oPosition = oView.Center
oPosition.y = oPosition.y - (oView.Height / 2 + 2.5)

'This inserts the sketched symbol and fills in the prompted entry.
Dim oSymbol As SketchedSymbol: oSymbol = oSheet.SketchedSymbols.Add(oSymDef, oPosition, , ,sPromptStrings)

Tags (1)
2 REPLIES 2
Message 2 of 3
cwhetten
in reply to: shmartin89

Try making the following changes highlighted in red:

 


@shmartin89 wrote:

 

Dim oApp As Application: oApp = ThisApplication
Dim oDoc As DrawingDocument: oDoc = oApp.ActiveDocument
Dim oSheet As Sheet: oSheet = oDoc.ActiveSheet

'This uses a sketch symbol with the name "'View On' View Label"
Dim oSymDef As SketchedSymbolDefinition: oSymDef = oDoc.SketchedSymbolDefinitions.Item("'View On' View Label")

'This is the selected view
Dim oView As DrawingView: oView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter,"Select View To Place Symbol:")

'This takes the label items of the selected view
'And adds it To an array that will link To the prompted entry
Dim sPromptStrings(2) As String
sPromptStrings(0) = oView.Name
sPromptStrings(1) = oView.ScaleString

oDoc = ThisApplication.ActiveDocument

Dim sSheet As Sheet

'create sheet number list
Dim oSheetList As New ArrayList
i = 0
s = "-"
For Each sSheet In oDoc.Sheets
i = i +1
oSheetList.add("SHT " & i)
Next
oSheetList.add(s)

'get user input
mySheet = (InputListBox("View taken form sheet number.", oSheetList, oSheetList(0), "Sheet Number Ref.", "Sheet Numbers"))

sPromptStrings(2) = Right(mySheet, Len(mySheet) - 4)

'This is the position for the sketched symbol under the selected view'
Dim oPosition As Point2d: oPosition = oView.Center
oPosition.y = oPosition.y - (oView.Height / 2 + 2.5)

'This inserts the sketched symbol and fills in the prompted entry.
Dim oSymbol As SketchedSymbol: oSymbol = oSheet.SketchedSymbols.Add(oSymDef, oPosition, , ,sPromptStrings)


Give that a try and see if it will work for you.  This makes it so your input box list displays like so:


Input List Box.PNG

 

But the value stored into your array will be just the sheet number.

 

Cameron Whetten
Inventor 2014

Please click "Accept as Solution" if this response answers your question.

Message 3 of 3
shmartin89
in reply to: cwhetten

Hi cwhetten

 

Thanks for the help.

 

I tried adding similar text such as ("SHT" + i) etc.

 

I also kept 'sPromptStrings(2) = mysheet' and it displays "SHT3" or whatever the user selects rather then just the number.

 

Sandy

 

 

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

Post to forums  

Autodesk Design & Make Report