Switching the style of a Balloon via Ilogic

Switching the style of a Balloon via Ilogic

hoeckesfeld
Enthusiast Enthusiast
870 Views
6 Replies
Message 1 of 7

Switching the style of a Balloon via Ilogic

hoeckesfeld
Enthusiast
Enthusiast

Hi all,

 

I try to get a balloon in an idw to switch styles upon selecting it and pressing my shortcut.

I tried the following ilogic rule and many variations of it. What am I doing wrong, can somebody help?

 

Public Class switchPosStyle
	
	Public Sub Main
		
		Dim oDocument As DrawingDocument = ThisApplication.ActiveDocument
		
		If oDocument.DocumentType <> kDrawingDocumentObject Then
			Exit Sub
		Else If oDocument.SelectSet.Count <> 1 Then	
			Exit Sub
		Else If Not TypeOf oDocument.SelectSet.Item(1) Is Balloon
			Exit Sub	
		Else
			For Each styleItem As BalloonStyle In oDocument.StylesManager.BalloonStyles
				If styleItem.Name = ("StyleNameIwantToSwitchTo") Then
					oDocument.SelectSet.Item(1).Style = styleItem
				End If
			Next	
		End If			
	End Sub
End Class

 

The styles are definitly available in the idw.

 

Thank you!

0 Likes
Accepted solutions (1)
871 Views
6 Replies
Replies (6)
Message 2 of 7

R.Mabery
Advocate
Advocate
Accepted solution

Something like this?

 

Dim oDocument As DrawingDocument = ThisApplication.ActiveDocument
Dim oSelectSet As SelectSet 
oSelectSet = oDocument.SelectSet
Dim oBalloon As Balloon
Dim oBalloonStyle As BalloonStyle
oBalloonStyle = oDocument.StylesManager.BalloonStyles.Item("New")
		
If oDocument.DocumentType <> kDrawingDocumentObject Then
	Exit Sub
Else If oSelectSet.Count <> 1 Then	
	Exit Sub
Else If Not TypeOf oSelectSet.Item(1) Is Balloon
	Exit Sub	
Else
	oBalloon = oSelectSet.Item(1)
	oBalloon.Style = oBalloonStyle
End If

Thanks,
Randy Mabery
Applications Expert
IMAGINiT Technologies
Message 3 of 7

hoeckesfeld
Enthusiast
Enthusiast

Thanks, it works! But could you maybe explain my mistake? I don't see what i've done essentially different, except for not using SelectSet..

0 Likes
Message 4 of 7

R.Mabery
Advocate
Advocate

Sure thing.  I believe that you were wanting to modify the style of a single balloon.  Your code was looking through the BalloonStyles in the Styles and Standards Editor and looking at their names.

 

What I presented is looking at the style of the currently selected balloon.

 

Maybe I missed what you were wanting to do?  

 


Thanks,
Randy Mabery
Applications Expert
IMAGINiT Technologies
0 Likes
Message 5 of 7

hoeckesfeld
Enthusiast
Enthusiast

No you are right, thats exactly what I want to do.

 

Yeah, I went through the style manager to find the style I want:

For Each styleItem As BalloonStyle In oDocument.StylesManager.BalloonStyles

 

But don't I then assign that style to the style of the currently selected balloon?

oDocument.SelectSet.Item(1).Style = styleItem

 

 

0 Likes
Message 6 of 7

R.Mabery
Advocate
Advocate

It doesn't know that your 

oDocument.SelectSet.Item(1)

is a Balloon and therefore doesn't understand the .Style property of it.

 

It's really the setting of the selected item to a Balloon that makes mine work.  I moved the additional stuff to the top just because that's my style of coding.  🙂

 


Thanks,
Randy Mabery
Applications Expert
IMAGINiT Technologies
0 Likes
Message 7 of 7

hoeckesfeld
Enthusiast
Enthusiast
Ah alright. I thought once the Balloon Object is selected the .style property would "find it's way" so to speak. Thank you.
0 Likes