iLogic view label below view

iLogic view label below view

Anonymous
Not applicable
2,082 Views
12 Replies
Message 1 of 13

iLogic view label below view

Anonymous
Not applicable

I would like to set the view label to below the view using iLogic, I know this is possible as I have seen it in a post somewhere before however now that I need it can't find it!

Anyonw know how to do this? I think it's only one line of code, any help would be useful!

0 Likes
2,083 Views
12 Replies
Replies (12)
Message 2 of 13

NSBowser
Advocate
Advocate

You haven't really indicated what you want the label to be.

 

Curtis did a good post on this which sets custom iproperties/parameters to the label.

 

Here is the basis of code which can set all the labels (here they are just enabled and set to their own name)

 

SyntaxEditor Code Snippet

Dim oDoc As DrawingDocument
oDoc = ThisDoc.Document
Dim oSheets As Sheets
Dim oViews As DrawingViews
oSheets = oDoc.Sheets
For Each oSheet As Sheet In oSheets
    oViews = oSheet.DrawingViews
    For Each oView As DrawingView In oViews
        oView.ShowLabel = True
        Try
            'add the custom iproperties to the view label
            oView.Label.FormattedText = "<DrawingViewName/>"
        Catch
            'do nothing if error
        End Try
    Next
Next

 


Best of Luck

---------------------------------------------------------------------------------------------------------------------------------
If you find this reply helpful or insightful, please use the 'Accept as Solution' or 'Kudos' button below.
Message 3 of 13

Anonymous
Not applicable

I have the basic code to add a label to the views I want, all I want is the line which changes the position from its default of above the view to below, as you can do through styles editor>standard> View Preferences>position and selecting below instead of above.

0 Likes
Message 4 of 13

frederic.vandenplas
Collaborator
Collaborator

You should approach the drawingstyle and set the different options there

Dim drawstyle As DrawingStandardStyle

....
Call draw.SetViewLabelDefaults(...)

If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
Message 5 of 13

NSBowser
Advocate
Advocate

My apologies, I didn't realize when you said place the view below that that was everything you wanted to do.

 

As Frederic indicated, the position of the label is easiest controlled by the Inventor Styles, as I assume you know this, then there is probably a reason you still want to set certain views programatically. Rather than tell you to change the style I'll do my best to help you move the view label.

 

Something to know, is that the 'position' of the view label is nothing a simple as a 'top' or 'bottom'. Those settings in the styles are simply instructions to help place the label correctly.

 

In order to change the position of a view that already exists using the API, you will have to modify the position (point2d) of the label in reference to the view it is attached. I would suggest getting the bottom edge of the view, offsetting your label down a set amount from it and centering it.

 

It might look something like the following. (this is just some back work, i didn't test any of this Smiley Happy)

 

Dim oView As DrawingView

xPos = oView.Left + (oView.Width/2)
yPos = oVIew.Top - oView.Height - 2 'Adjust the 2 as needed

oVIew.Label.Position.x = xPos
oView.Label.Position.y = yPos

 

If  you have trouble applying this solution let us know, we'll probably need a sample to work with if it's more complex than have view need label...


Best of Luck

---------------------------------------------------------------------------------------------------------------------------------
If you find this reply helpful or insightful, please use the 'Accept as Solution' or 'Kudos' button below.
0 Likes
Message 6 of 13

Anonymous
Not applicable

Well this is what I'm working with:

Dim oDoc As DrawingDocument: oDoc = ThisDoc.Document
Dim oSheet As Sheet
Dim oView As DrawingView

For Each oSheet In oDoc.Sheets
    For Each oView In oSheet.DrawingViews
         If oview.IsFlatPatternView=True Then            
            oView.showlabel=True
            oView.label.formattedtext= "FLAT PATTERN" & " (" & oView.ScaleString & ")"
        End If    
    Next
Next

 I definitely feel like there should be a way to simply change it as I have with the visibility and format which are also part of the drawing style.

 

I did try to change the format to no avail, any further help?

 

Another question, is there a way for illogic to give you options of what you could write next, as vba does?

0 Likes
Message 7 of 13

Anonymous
Not applicable
I'm trying to not use this method, I do know this is a possibility but I'm sure I ran a simple code from somewhere which switched it from top to bottom, similar to toggling the visibility 😞
0 Likes
Message 8 of 13

frederic.vandenplas
Collaborator
Collaborator

Be aware that the change seems only be visible for newly created drawingviews.

For some reason the label does not change for existing drawing views

If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
0 Likes
Message 9 of 13

Anonymous
Not applicable

Then I'm not sure this is what I need, I need it so that it works in the same way showlabel works unfortunately. Thank you anyway

0 Likes
Message 10 of 13

NSBowser
Advocate
Advocate

Unfortunately, how we feel about the API does not make it so. As far as I can tell, the only way to control the position of a pre-existing label is to do as I have indicated or similar. 

 

I do not know what you mean or are asking when you say 'change the format, to no avail' can you clarify. What formatting? Text format? Font? Size?

 

Lastly, the feature you are referencing is called IntelliSense, which is a feature of the code editor (i.e. visual studio, vba) It does not exist in the iLogic interface. However, you should be able to find all of the information you need in the Programming Help, which gives a relatively comprehensive list of all methods and properties for each object. (I have found a few methods which were not in the help, to my despair)


Best of Luck

---------------------------------------------------------------------------------------------------------------------------------
If you find this reply helpful or insightful, please use the 'Accept as Solution' or 'Kudos' button below.
Message 11 of 13

Anonymous
Not applicable

I think I might just resort to editing the style. The difficulty with that though is doing it when no one else is on the project!

0 Likes
Message 12 of 13

NSBowser
Advocate
Advocate

If you want the view label affected everywhere, then I agree to modify the Style. However, if you want sheet metal view labels to be unique, than creating an iLogic routine to do so sounds reasonable. I would simply modify your code as shown.

 

 

Dim oDoc As DrawingDocument: oDoc = ThisDoc.Document
Dim oSheet As Sheet
Dim oView As DrawingView

For Each oSheet In oDoc.Sheets
    For Each oView In oSheet.DrawingViews
         If oview.IsFlatPatternView=True Then            
            oView.showlabel=True
            oView.label.formattedtext= "FLAT PATTERN" & " (" & oView.ScaleString & ")"
xPos = oView.Left + (oView.Width/2) yPos = oVIew.Top - oView.Height - 2 'Adjust the 2 as needed oView.Label.Position.x = xPos oView.Label.Position.y = yPos
oView.Label.ConstrainToBorder = True
End If Next Next

 

 


Best of Luck

---------------------------------------------------------------------------------------------------------------------------------
If you find this reply helpful or insightful, please use the 'Accept as Solution' or 'Kudos' button below.
0 Likes
Message 13 of 13

A.Acheson
Mentor
Mentor

Old post but I added in the piece missing to physically make the label move in relation to border position.

"oPosPt = ThisApplication.TransientGeometry.CreatePoint2d(xPos, yPos)"

Thanks to the contributors this solved my updates needed. 

 

Dim oDoc As DrawingDocument: oDoc = ThisDrawing.Document
Dim oSheet As Sheet
Dim oView As DrawingView

For Each oSheet In oDoc.Sheets
    For Each oView In oSheet.DrawingViews
        ' If oView.IsFlatPatternView=True Then            
            oView.ShowLabel=True
            oView.Label.FormattedText= "FLAT PATTERN" & " (" & oView.ScaleString & ")"
			
			Dim xPos As Double = Nothing
			xPos= oView.Left + (oView.Width / 2)
            
			Dim yPos As Double = Nothing
			yPos = oView.Top - oView.Height -2'Adjust the 2 as needed
			
			oPosPt = ThisApplication.TransientGeometry.CreatePoint2d(xPos, yPos)

            oView.Label.Position = oPosPt
        
            oView.Label.ConstrainToBorder = True
        'End If    
    Next
Next

 

 

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