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: 

Help with view label iLogic rule.

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Ajcraig99
2590 Views, 5 Replies

Help with view label iLogic rule.

Hello, i have no experience with iLogic rules and need some help to modify one i found online to suit my needs.

 

I need to change the view label properties in the styles editor to show custom properties in the view label, Ofcourse the only way to do this is to manualy edit each view label as the styles editor does not allow custom properties.

 

I need each view label to show the below. (see attached image)

 

"View" is to be the same value as default. (5mm text size)

"MARK No" should be plane text (5mm text) followed by the custom model property "Mark_No)

"REF" needs to be plane text (3.5mm) followed by the custom model property "CLIENT DRG No)

"SCALE" needs to be 3.5mm text followed by the default view scale parameter

 

 

 

 

The iLogic rule i found is below and is to be used in the .idw template, I am hoping somebody can decipher it and show me what i need to edit??

 

 

 

'start of ilogic code
Dim oDoc As DrawingDocument:  oDoc = ThisDoc.Document
oModel = ThisDoc.ModelDocument

Dim oSheets As Sheets
Dim oSheet As Sheet
Dim oViews As DrawingViews
Dim oView As DrawingView

oSheets = oDoc.Sheets

For Each oSheet In oSheets
oViews = oSheet.DrawingViews
    For Each oView In oViews
    oView.ShowLabel = True
        Try
        'get the property ID for these custom iProperties from the model referenced by the view
        o_iPropID_1 = oModel.PropertySets.Item("User Defined Properties").Item("My_iProp_1").PropId
        o_iPropID_2 = oModel.PropertySets.Item("User Defined Properties").Item("My_iProp_2").PropId
        Catch
        'here you could add a message that one or more of the custom iProperties were not found
        End Try
        
        Try
        'format the custom iproperty string and add the property ID
        oString1 = "<Property Document='model' PropertySet='User Defined Properties' " _
        &  "Property='My_iProp_1' FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' PropertyID='" _
        & o_iPropID_1  & "'>My_iProp_1</Property><Br/>"
        'format the custom iproperty string and add the property ID
        oString2 = "<Property Document='model' PropertySet='User Defined Properties' " _
        &  "Property='My_iProp_2' FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' PropertyID='" _
        & o_iPropID_2  & "'>My_iProp_2</Property><Br/>"

        'add the custom iproperties to the view label
        oView.Label.FormattedText = "<DrawingViewName/><Br/>"  &  oString1 &  oString2
        Catch
        'do nothing if error
        End Try
    Next
Next
'end of ilogic code




5 REPLIES 5
Message 2 of 6

May I know which version of Inventor are you using at the moment. Is this your entire ilogic code ?


Vinod Balasubramanian
AutoCAD Industry Support & Escalation Lead

Message 3 of 6

Gday Vinod,

 

We are using Inventor Pro 2014 SP1 Update 3

Message 4 of 6

Hi ajcraig99,

 

Here is a quick example rule to format to your needs. Hopefully you can determine how the code works. but just post back if it does not work for you, or if you have questions.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

'start of ilogic code
'specify font
sFont = "Arial"
sFSize1 = 0.5 'font size in cm
sFSize2 = 0.35 'font size in cm

sString1 = "<StyleOverride Font='" & sFont & "' FontSize='" & sFSize1 & "' Underline='True'>" & _
"<DrawingViewName/></StyleOverride>"

sString2 = "<StyleOverride Font='" & sFont & "' FontSize='" & sFSize1 & "'>Mark No: </StyleOverride>"
sString3 = "<StyleOverride Font='" & sFont & "' FontSize='" & sFSize1 & "'>" _
& "<Property Document='model' PropertySet='User Defined Properties' Property='Mark No' " & _
"FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' PropertyID='7'>Mark No</Property></StyleOverride>"

sString4 = "<StyleOverride Font='" & sFont & "' FontSize='" & sFSize2 & "'>REF: </StyleOverride>"
sString5 = "<StyleOverride Font='" & sFont & "' FontSize='" & sFSize2 & "'>" _
& "<Property Document='model' PropertySet='User Defined Properties' Property='Client DRG No' " &  _
"FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' PropertyID='6'>Client DRG No</Property></StyleOverride>"

sString6 = "<StyleOverride Font='" & sFont & "' FontSize='" & sFSize2 & "'>SCALE: </StyleOverride>"
sString7 = "<StyleOverride Font='" & sFont & "' FontSize='" & sFSize2 & "'>" & _
"<DrawingViewScale/></StyleOverride>"


Dim oDoc As DrawingDocument:  oDoc = ThisDoc.Document
oModel = ThisDoc.ModelDocument

Dim oSheets As Sheets
Dim oSheet As Sheet
Dim oViews As DrawingViews
Dim oView As DrawingView

oSheets = oDoc.Sheets

For Each oSheet In oSheets

oViews = oSheet.DrawingViews
    For Each oView In oViews
    'make view label visible
    oView.ShowLabel = true
    
    'add lines to the view label
    'break line using:  "<Br/>"
    oView.Label.FormattedText = _
    sString1 & "<Br/>" & _
    sString2 & sString3 & "<Br/>" & _
    sString4 & sString5 & "<Br/>" & _
    sString6 & sString7

    Next
Next
'end of ilogic code

 

Message 5 of 6

Thanks Curtis, Much appreciated,

 

Im having trouble getting the "' Underline='False'>"

value to work on string 2 to string 7. is it also possible to make this for "Base view" only?

 

P.S how do i sub to your blog without rss feeds?

Message 6 of 6

Hi ajcraig99,

 

When working with view labels I use an intermediate ilogic rule to capture the text formatting. Here is how I get the formatting to use in the rule:

 

  1. First I edit a view label and set the formatting as I want it. Note that I typically do this for each line of the view label separately.Autodesk Inventor View Label iLogic 001.png
  2. Then I select the view and run this iLogic rule:
    Dim oSSet As SelectSet = ThisDoc.Document.SelectSet
    If oSSet.count = 0 Then
    	MessageBox.Show("You must select a drawing view first", "iLogic")
    Exit Sub
    End If
    'Reference to the drawing view from the 1st selected object
    Dim oView As DrawingView = trycast(oSSet.item(1), DrawingView)
    
    If oView IsNot Nothing Then
    	'turn view label visibility on
    	oView.ShowLabel = True
    	'capture the current view label
    	ViewLabel = oView.Label
    	Try
    	'return the value
    	MessageBox.Show(oView.Label.FormattedText, _
    	 "iLogic - Go to the Summary iproperties to copy this information")
    	'write the value to the drawings comments property
    	iProperties.Value("Summary", "Comments") = oView.Label.FormattedText
    	Catch
    	'do nothing if error
    	End Try 
    Else
    	MessageBox.Show("The selected object is not a drawing view", "iLogic")
    End If

     

  3. Then go to the drawing's iProperties and look at the Summary tab, and copy the information found there:Autodesk Inventor View Label iLogic 002.png
  4. Then I create or edit the final rule and use that formatting to create the strings as needed.

 

Give this a try and see if you can get the results you're after.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

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

Post to forums  

Autodesk Design & Make Report