Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic - move Balloon

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
j.pavlicek
472 Views, 4 Replies

iLogic - move Balloon

Hello,

I'm trying to move a Balloon to other position, but keep getting Member not found error:

 

jpavlicek_0-1630416894809.png

 

This is my code:

Dim oBalloon As Object

Dim oPoint2d As Point2d
With oBalloon
	'Check for supported type
	If .type = kBalloonObject Then
		Logger.Debug("TypeCheck OK")
		If oPoint2d Is Nothing Then 
			Logger.Debug("Creating Point2d")
			oPoint2d = ThisApplication.TransientGeometry.CreatePoint2d(2, 2)
			Logger.Debug("Point2d created")
		End If
		Logger.Debug("X/Y = " & oPoint2d.X & " / " & oPoint2d.Y)
		
		.Position = oPoint2d
		Logger.Debug("Position changed")
		
		Logger.Debug("x = " & .position.X)
		Logger.Debug("y = " & .position.Y)
	Else
		Logger.Info("---NOT supported type of object")
	End If
End With	

 

iLogicLog output:

 

 

DEBUG|TypeCheck OK
DEBUG|Creating Point2d
DEBUG|Point2d created
DEBUG|X/Y = 2 / 2

 

 

 

What is problem here?

 

Thanks for help.



Inventor 2022, Windows 10 Pro
Sorry for bad English.
Labels (1)
4 REPLIES 4
Message 2 of 5
WCrihfield
in reply to: j.pavlicek

My first thought...Within a With statement, I believe you can only retrieve or read member values and invoke its methods.  I don't think you are allowed to modify or set member values.  So, at the point you try to set .Position = oPoint2d, it threw an error.  Read the page at the provided link.  Try doing it without using the With block.

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you want and have time, I would appreciate your Vote(s) for My IDEAS :light_bulb:or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 5
j.pavlicek
in reply to: WCrihfield

Thank you for your reply.

 

I edited the code  - removed the With statement and qualify all used Balloon object members and methods.

Dim oBalloon As Object

Dim oPoint2d As Point2d

'Check for supported type
If oBalloon.type = kBalloonObject Then
	Logger.Debug("TypeCheck OK")
	If oPoint2d Is Nothing Then 
		Logger.Debug("Creating Point2d")
		oPoint2d = ThisApplication.TransientGeometry.CreatePoint2d(2, 2)
		Logger.Debug("Point2d created")
	End If
	Logger.Debug("X/Y = " & oPoint2d.X & " / " & oPoint2d.Y)
	
	oBalloon.Position = oPoint2d
	Logger.Debug("Position changed")
	
	Logger.Debug("x = " & oBalloon.position.X)
	Logger.Debug("y = " & oBalloon.position.Y)
Else
	Logger.Info("---NOT supported type of object")
End If

But no changes in the result.

 



Inventor 2022, Windows 10 Pro
Sorry for bad English.
Message 4 of 5
Michael.Navara
in reply to: j.pavlicek

Is it much better to use specific type when possible. Not base type Object and LateBinding for work with them. Your code doesn't work but this modified works well

 

Dim pick As Object = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingBalloonFilter, "Pick balloon")
Dim oBalloon As Balloon = pick
Dim oPoint2d As Point2d = Nothing
With oBalloon
    'Check for supported type
    If .Type = ObjectTypeEnum.kBalloonObject Then
        Logger.Debug("TypeCheck OK")
        If oPoint2d Is Nothing Then
            Logger.Debug("Creating Point2d")
            oPoint2d = ThisApplication.TransientGeometry.CreatePoint2d(2, 2)
            Logger.Debug("Point2d created")
        End If
        Logger.Debug("X/Y = " & oPoint2d.X & " / " & oPoint2d.Y)

        .Position = oPoint2d
        Logger.Debug("Position changed")

        Logger.Debug("x = " & .Position.X)
        Logger.Debug("y = " & .Position.Y)
    Else
        Logger.Info("---NOT supported type of object")
    End If
End With
Message 5 of 5
j.pavlicek
in reply to: Michael.Navara

@Michael.Navara You are right! It seems late binding is the problem here.

 

Thank you!



Inventor 2022, Windows 10 Pro
Sorry for bad English.

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

Post to forums  

Autodesk Design & Make Report