Renaming the Sheet With a Prompted Entry

Renaming the Sheet With a Prompted Entry

Anonymous
Not applicable
942 Views
5 Replies
Message 1 of 6

Renaming the Sheet With a Prompted Entry

Anonymous
Not applicable

Hi Everyone,

 

In my Title Block, I have a field called Sheet Name that is driven off of a prompted entry.  I was hoping to pull the text in that field and use it to also rename the sheet in the browser.  I tried looking around the forums but, couldn't find the answer.

 

If anyone can point me in the right direction, I would be very appreciative.

 

Thanks,

Paul

0 Likes
Accepted solutions (1)
943 Views
5 Replies
Replies (5)
Message 2 of 6

Sergio.D.Suárez
Mentor
Mentor

Hi, Could you attach an image to better describe the problem? to know the name, type of entry. Regards!


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

Message 3 of 6

Anonymous
Not applicable

Thank's for replying.

 

I'm not sure what you need so, I apologize if I give you too much info.

 

When I first open a drawing or create a new sheet, I get a dialog box asking for the Sheet Name.  The Sheet Name Property Field is a labeled as Prompted Entry.  It isn't pulling from a regular or custom iProperty field. 

 

Prompted Dialog Box.PNG

 

Whatever is entered here, is put into the Title Block.

TB.PNG

 

Here is a image of the Format Text window for more info

Sheet Description.PNG

 

 

We are hoping to get the name given to the sheet (ABC123) to automatically pop up as the sheet name in the Browser to the left. 

 

Browser.PNG

 

I hope that helped explain it a little better.

 

Thanks,

Paul

0 Likes
Message 4 of 6

dean.morrison
Advocate
Advocate

Hi,

 

I think this might do what you want.. Its VBA so may need modification if you want iLogic.

 

-------------------------

Set oDrawingDoc = ThisApplication.ActiveDocument

If oDrawingDoc.DocumentType = kDrawingDocumentObject Then

Set oSheet = oDrawingDoc.ActiveSheet

Dim oTitleBlock As TitleBlock
Set oTitleBlock = oSheet.TitleBlock

If Not oTitleBlock Is Nothing Then

Set oSketchDef = oTitleBlock.Definition.Sketch

Set oTextBoxes = oSketchDef.TextBoxes

For j = 1 To oTextBoxes.Count

If oTextBoxes.Item(j).Text = "<SHEET NAME>" Then
Set iTextBox = oTextBoxes.Item(j)
RequiredText = oTitleBlock.GetResultText(iTextBox)
End If

Next j

End If

Dim oPane As BrowserPane
Set oPane = oDrawingDoc.BrowserPanes.Item(1)
Dim oNode As BrowserNode

Set oNode = oPane.TopNode.BrowserNodes.Item(2)

oNode.NativeObject.Name = RequiredText

 

End If

-------------------------

 

Hope that helps.

 

Dean.

Message 5 of 6

Anonymous
Not applicable

Thank you! Looking through the code, it seems to be what I am looking for.  However, after i removed the Let and Set commands (Inventor doesn't like them anymore) I get the following error;

 

Error in rule: Rule0, in document: Drawing2

The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

 

Below is the code I am running.  I'm not sure what Parameter it is looking for.  Is the "J" in the code calling out the cell in the titleblock?  Is the parameter the error referring to the <SHEET NAME>?

 

oDrawingDoc = ThisApplication.ActiveDocument

If oDrawingDoc.DocumentType = kDrawingDocumentObject Then

oSheet = oDrawingDoc.ActiveSheet

Dim oTitleBlock As TitleBlock
oTitleBlock = oSheet.TitleBlock

If Not oTitleBlock Is Nothing Then

oSketchDef = oTitleBlock.Definition.Sketch

oTextBoxes = oSketchDef.TextBoxes

For j = 1 To oTextBoxes.Count

If oTextBoxes.Item(j).Text = "<SHEET NAME>" Then
	iTextBox = oTextBoxes.Item(j)
RequiredText = oTitleBlock.GetResultText(iTextBox)
End If

Next j

End If

Dim oPane As BrowserPane
oPane = oDrawingDoc.BrowserPanes.Item(1)
Dim oNode As BrowserNode

oNode = oPane.TopNode.BrowserNodes.Item(2)

oNode.NativeObject.Name = RequiredText

End If

Thanks again for your help,

Paul

 

 

0 Likes
Message 6 of 6

Anonymous
Not applicable
Accepted solution

I found a pretty decent work around here.  Thanks again for your help though.  You make these forums amazing.

 

0 Likes