Hello,
I'm trying to move a Balloon to other position, but keep getting Member not found error:
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.
Solved! Go to Solution.
Solved by Michael.Navara. Go to Solution.
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
(Not an Autodesk Employee)
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.
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
@Michael.Navara You are right! It seems late binding is the problem here.
Thank you!
Can't find what you're looking for? Ask the community or share your knowledge.