Trying to create custom iProperties using prompted properties

Trying to create custom iProperties using prompted properties

Anonymous
Not applicable
391 Views
2 Replies
Message 1 of 3

Trying to create custom iProperties using prompted properties

Anonymous
Not applicable

I've been looking online and in the forum, found a few things but couldn't make things work. I have a "prompted property field" window that pops up, and all I want to do is convert those properties into iProperties so I can autofill text boxes and property fields in other sheets.

 

Found this online (and a few others, but this was the simplest), but I can't quite get it to work.

 

 

On Error Resume Next
'https://www.cadlinecommunity.co.uk/hc/en-us/articles/203292761
Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
Dim oPromptEntry

Dim oCurrentSheet
oCurrentSheet = oDoc.ActiveSheet.Name

i = 1
For Each oSheet In oDoc.Sheets
  'i = i+1
  ThisApplication.ActiveDocument.Sheets.Item(i).Activate
       oTitleBlock=oSheet.TitleBlock
    oTextBoxes=oTitleBlock.Definition.Sketch.TextBoxes
    For Each oTextBox In oTitleBlock.Definition.Sketch.TextBoxes
    Select oTextBox.Text
        Case "DRAWING NUMBER"
            oPromptEntry  =  oTitleBlock.GetResultText(oTextBox)
            iProperties.Value("Project", "Part Number")=oPromptEntry

    End Select
    Next
Next

ThisApplication.ActiveDocument.Sheets.Item(oCurrentSheet).Activate

ddoc = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName)
'iProperties.Value(ddoc, "Project", "Part Number") = iProperties.Value("Project", "Part Number")
iProperties.Value(ddoc, "Custom", "Drawing No") = iProperties.Value("Project", "Enter Product M2M NUMBER")
iLogicVb.UpdateWhenDone = True

 

 I have coded in other languages but for some reason (maybe I'm just too tired at work) this ones throwing me for a loop.

 

If someone could either help explain what I should change or suggest different code, that would be amazing. 

0 Likes
392 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor

So, you're trying to edit the text portions of your TitleBlock by code?

It all depends on how your title block was set up.

I can't tell, just based on your image, how that data is defined within your TitleBlock.

One option is an AttributeSet.  If that's the case, that code won't help you, because it doesn't access the TitleBlock's AttributeSet.

Other options are:

  • Standard iProperties (from either Drawing Document or Model Document)
  • Custom iProperties (from either the Drawing or Model documents)
  • Drawing Properties (Number of Sheets)
  • Sheet Properties
  • _Piping Style
  • Physical Properties of the Model
  • Sheet Metal Properties
  • Parameters

All these other 'Properties' are usually set up from a regular 'Format Text' dialog box, by using the available drop-down menus within it, then clicking the 'Insert' button.

Most of these values can be either retrieved or changed from the iProperties of either the Drawing, or Model files.

Can you confirm which way your title block is set-up?

Or perhaps you could attach a non-confidential drawing file, with the title block, so we can investigate?

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

J-Camper
Advisor
Advisor

It was all working for me except the last iProperty value, where it looks like you want to pull a "Custom" iProperty in the drawing but you are looking for it in the "Project" section:

 

iProperties.Value(ddoc, "Custom", "Drawing No") = iProperties.Value("Custom", "Enter Product M2M NUMBER")

 

edit:

I didn't look at the image before testing the code, now i see that "Enter Product M2M NUMBER" is a prompted entry.

 

I would probably set up a list of strings and pull out all the Prompted entry values at once, that loop should work, then pass them into the model document iProperties by referencing the string list:

On Error Resume Next
'https://www.cadlinecommunity.co.uk/hc/en-us/articles/203292761
Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet
Dim oPromptEntry As New List(Of String)
Dim oCurrentSheet = oDoc.ActiveSheet.Name

i = 1
For Each oSheet In oDoc.Sheets
  'i = i+1
  ThisApplication.ActiveDocument.Sheets.Item(i).Activate
       oTitleBlock=oSheet.TitleBlock
    oTextBoxes = oTitleBlock.Definition.Sketch.TextBoxes
    For Each oTextBox In oTitleBlock.Definition.Sketch.TextBoxes
    Select oTextBox.Text
        Case "DRAWING NUMBER"
            oPromptEntry.Add(oTitleBlock.GetResultText(oTextBox))
            iProperties.Value("Project", "Part Number") = oPromptEntry.Item(0)
		Case "Enter Product M2M NUMBER"
            oPromptEntry.Add(oTitleBlock.GetResultText(oTextBox))
    End Select
    Next
Next

oPromptEntry.Add("testing")

ThisApplication.ActiveDocument.Sheets.Item(oCurrentSheet).Activate

ddoc = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName)
iProperties.Value(ddoc, "Project", "Part Number") = oPromptEntry.Item(0)
iProperties.Value(ddoc, "Custom", "Drawing No") = oPromptEntry.Item(1)
iLogicVb.UpdateWhenDone = True
0 Likes