Trying to Take Value from title block to use in iProperties

Trying to Take Value from title block to use in iProperties

Anonymous
Not applicable
1,026 Views
7 Replies
Message 1 of 8

Trying to Take Value from title block to use in iProperties

Anonymous
Not applicable

New here but have used a lot of the info whilst learning iLogic but couldn't find what I was looking for for this one.

 

I'm writing something which has sent a designed name from my .ipt file to the .idw and is being used in the Title Block as the Title. However, in the .idw I would like that same title to be in the iProperties version of it. I am running into this error: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG)), and it specifically mentions the .GetResultText line which I cannot find an alternative for (or even any real mention of it online). This code (much like most of mine) has been butchered from another user on this site I believe so credit where credit is due.

 

Any help would be much appreciated. 

 

 

Dim oDoc As Document
Dim oSheet As Sheet
Dim oTB1 As TitleBlock
Dim titleDef As TitleBlockDefinition
Dim oPrompt As TextBox
Dim title As String
Dim titleVal As String


oDoc = ThisApplication.ActiveDocument
oSheet = oDoc.Activesheet
oTB1 = oSheet.TitleBlock
titleDef = oTB1.Definition

For Each defText As TextBox In titleDef.Sketch.TextBoxes
	If defText.Text = "<TITLE>" Then
		oPrompt = defText
		Exit For
	End If
Next

title = oTB1.GetResultText(oPrompt)
iProperties.Value("Summary", "Title") = title

Logger.Debug("Title: " & title)
0 Likes
Accepted solutions (1)
1,027 Views
7 Replies
Replies (7)
Message 2 of 8

Sergio.D.Suárez
Mentor
Mentor

Hello, the first thing I would do in ilogic would be to remove the ambiguous "Texbox"
and I would have something like this

Dim oDoc As Document = ThisApplication.ActiveDocument
Dim oSheet As Sheet  = oDoc.Activesheet
Dim oTB1 As TitleBlock = oSheet.TitleBlock
Dim titleDef As TitleBlockDefinition = oTB1.Definition
Dim title As String

For Each defText In titleDef.Sketch.TextBoxes
	If defText.Text = "<TITLE>" Then
		oPrompt = defText
		Exit For
	End If
Next

title = oTB1.GetResultText(oPrompt)
iProperties.Value("Summary", "Title") = title

But for it to work, there should be a text box that only contains the string "<TITLE>", if the box for example were "My Title: <TITLE>" it would throw an error.

 

On the other hand, instead of accessing the titleblock, I would directly access the model document. He would take the model and extract the property directly from there. If there is no view, you leave the rule without taking any action.

Dim doc As Document = ThisDrawing.ModelDocument
If doc Is Nothing Then Exit Sub
Dim oTitle As String = doc.PropertySets("Inventor Summary Information").Item("Title").Value
iProperties.Value("Summary", "Title") = oTitle


I hope this helps with your problem. 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 8

Anonymous
Not applicable

Hi Sergio,

 

Appreciate your help immensely. Unfortunately it's still not working but your second method made me think. the reason I am trying to take the title from the block to place in iProperties is because I have made a small automated process. I change the dimension on an .ipt model and when I hit OK on the form, the rule fires which loads up the template, and allows a quick application of the sketch to the template. When this occurs, the title in the block is altered so that it displays what size the dimension is and this happens automatically as the dimension is changed. What made me think was if there was a way to do essentially what I've done already but rather than from iProperty & iLogic together to the title block, can I write in a small something which will force the iProperty title in the drawing?

 

I hope this makes sense, if it doesn't I'm happy to supply anything to help as I appreciate your time. 

0 Likes
Message 4 of 8

SharkDesign
Mentor
Mentor

If I understand you correctly, what you want in your iProperties is from a parameter?

 

You don't even need iLogic for this. 

 

In the parameters panel, tick the 'export' box next to the parameter you want in the iProperties. 

Go to iProperties, say you want it in part number, type in that box

=<Parameter name>

When you press enter, the text will change to show the value. 

You can also write things like

=Extrusion length - <Parameter name> and it'll produce something like

Extrusion length - 500mm

 

The iProperty will update when the parameter changes, but you may need a refresh in your ilogic code to make it do it before you save your new file. 

 

If you don't want the unit type you can remove it in the 'custom format' option which you get from right clicking the value in the parameters window. 

  Inventor Certified Professional
0 Likes
Message 5 of 8

Anonymous
Not applicable

I wasn't aware you could do that! Unfortunately I don't have the option for exporting this parameter (a user parameter, should that make a difference), which is odd as it's the only parameter (user, reference, or model) that I can't export. Do you have any idea how to remedy that?

0 Likes
Message 6 of 8

SharkDesign
Mentor
Mentor

Yeah, it was about 5 years before someone showed me that!!

 

Just reference your custom parameter in the main parameters

 

so like

user parameters

yo=50

 

model parameters

d25 = yo

 

  Inventor Certified Professional
0 Likes
Message 7 of 8

Anonymous
Not applicable

Hi Guys,

 

Just wanted to say thank you for your help but it looks like I've worked my way around it. I was way overthinking it and end result meant I traded in 75 lines of code for 2 lines. I'll attach the end result but it appears that the excessive amounts of variables I had declared were wreaking some havoc. I was not aware that you could poach iProperty values from other files.

Dim modelname As String
Dim odoc As Document

iLogicForm.Show("Save Drawing")

modelname = iProperties.Value("[FILENAME]", "Summary", "Title")

If saved = True Then
	ThisDoc.Document.saveasinventordwg("[FILEPATH]" & modelName & ".dwg", True)
	
End If

0 Likes
Message 8 of 8

SharkDesign
Mentor
Mentor
Accepted solution

You can also do it with occurrence name in an assembly

 

iProperties.Value(occ.name, "Summary", "Title")

 

  Inventor Certified Professional