iLOGIC Code to Recognize Sheet Number

iLOGIC Code to Recognize Sheet Number

SECOJOSE
Contributor Contributor
223 Views
3 Replies
Message 1 of 4

iLOGIC Code to Recognize Sheet Number

SECOJOSE
Contributor
Contributor

I have ilogic in a drawing that selects the model state of a drawing view, and the code that i use is dependent on the sheet number to specify the view. Is there code that returns the value of the sheet based on the name of the sheet? Or is there a way to reference a drawing view that is not dependent on the sheet number? The line im using for view selection:

 

ThisDrawing.Sheets.ItemByName("SHEET NAME:1").View("VIEW NAME").View.SetActiveModelState(...

 

0 Likes
224 Views
3 Replies
Replies (3)
Message 2 of 4

A.Acheson
Mentor
Mentor

Hi @SECOJOSE 

 

If you just want to select a view manually and set modelstate use the pick function from the Inventor API

Dim drawView As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select a drawing view")
	drawView.SetActiveModelState("ModelState")

If you want to get the active sheet then use iLogic API

ThisDrawing.ActiveSheet

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 4 of 4

WCrihfield
Mentor
Mentor

Here is a commonly used tactic to separate the sheet name and the sheet number, if needed.  It gets the value of the Sheet.Name property, then uses the vb.net Split() method on it, using the ":" character as the separator, to get an Array of Strings.  Then either gets the first String in that array, as its pure name, or gets the last String in that array as the sheet's number, then converts that numerical String into an Integer, using the CInt() converter function.  Then just shows you the result in a simple MsgBox call

Dim oDDoc As DrawingDocument = ThisDoc.Document
Dim oSheet As Inventor.Sheet = oDDoc.ActiveSheet
Dim sSheetName As String = oSheet.Name.Split(":").First
Dim iSheetNumber As Integer = CInt(oSheet.Name.Split(":").Last)
MsgBox("Active Sheet Name = " & sSheetName _
& vbCrLf & "Active Sheet Number = " & iSheetNumber.ToString, vbInformation,"iLogic")

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes