Visible sketch with ilogic (in an assemble)

Visible sketch with ilogic (in an assemble)

Z0methink
Enthusiast Enthusiast
598 Views
5 Replies
Message 1 of 6

Visible sketch with ilogic (in an assemble)

Z0methink
Enthusiast
Enthusiast

This code is good:

 

Visible = True

prt = "Part:1"

sktch = "Sketch"

Dim compOcc = Component.InventorComponent(prt)

Dim oSk As PlanarSketch = compOcc.Definition.Sketches.Item(sktch)

Dim oSkProx As PlanarSketchProxy = Nothing

Call compOcc.CreateGeometryProxy(oSk, oSkProx)

oSkProx.Visible = Visible

 

This code gives an error message:

 

Sub Main()

Visible = True

prt = "Part:1"

sktch = "Sketch"

SketchVisible

End Sub


Sub SketchVisible()

Dim compOcc = Component.InventorComponent(prt)

Dim oSk As PlanarSketch = compOcc.Definition.Sketches.Item(sktch)

Dim oSkProx As PlanarSketchProxy = Nothing

Call compOcc.CreateGeometryProxy(oSk, oSkProx)

oSkProx.Visible = Visible

End Sub

 

Message: "Component : The Component named "Nothing" was Not found."

 Why?

0 Likes
Accepted solutions (1)
599 Views
5 Replies
Replies (5)
Message 2 of 6

Z0methink
Enthusiast
Enthusiast

This code gives an error message:

 

Sub Main()

Visible = True

prt = "Part:1"

sktch = "Sketch"

SketchVisible

End Sub

 

Sub SketchVisible()

Dim compOcc = Component.InventorComponent(prt)

Dim oSk As PlanarSketch = compOcc.Definition.Sketches.Item(sktch)

Dim oSkProx As PlanarSketchProxy = Nothing

Call compOcc.CreateGeometryProxy(oSk, oSkProx)

oSkProx.Visible = Visible

End Sub

 

Message: "Component : The Component named "Nothing" was Not found."

 Why?

0 Likes
Message 3 of 6

andrewiv
Advisor
Advisor
Accepted solution

If you want to use variables in multiple sub routines you have to pass them to the sub routine or make them global variables.  Here are the two ways of doing it.  I commented out the first part that shows passing the variables.

'Sub Main()
'Dim Visible As Boolean = True
'Dim prt As String = "Part:1"
'Dim sktch As String = "Sketch"
'	Call SketchVisible(Visible, prt, sktch)
'End Sub

'Sub SketchVisible(Visible As Boolean, prt As String, sktch As String)
'	Dim compOcc = Component.InventorComponent(prt)
'	Dim oSk As PlanarSketch = compOcc.Definition.Sketches.Item(sktch)
'	Dim oSkProx As PlanarSketchProxy = Nothing
'	Call compOcc.CreateGeometryProxy(oSk, oSkProx)
'	oSkProx.Visible = Visible
'End Sub

Class thisRule
Dim Visible As Boolean = True
Dim prt As String = "Part:1"
Dim sktch As String = "Sketch"
Sub Main()
	Call SketchVisible()
End Sub

Sub SketchVisible()
	Dim compOcc = Component.InventorComponent(prt)
	Dim oSk As PlanarSketch = compOcc.Definition.Sketches.Item(sktch)
	Dim oSkProx As PlanarSketchProxy = Nothing
	Call compOcc.CreateGeometryProxy(oSk, oSkProx)
	oSkProx.Visible = Visible
End Sub
End Class

 

Andrew In’t Veld
Designer / CAD Administrator

Message 4 of 6

marcin_otręba
Advisor
Advisor

Try now:

But honestly i do not now what you want to do?

 

Sub Main()

Visible = True

 

SketchVisible

End Sub

 

Sub SketchVisible()

prt = "Part:1"

sktch = "Sketch"

Dim compOcc = Component.InventorComponent(prt)

Dim oSk As PlanarSketch = compOcc.Definition.Sketches.Item(sktch)

Dim oSkProx As PlanarSketchProxy = Nothing

Call compOcc.CreateGeometryProxy(oSk, oSkProx)

oSkProx.Visible = Visible

End Sub

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 5 of 6

Z0methink
Enthusiast
Enthusiast

Thank you very very much! Works! I just simplified the code for ilogic (this worked too):

Sub main ()
Visible = True
prt = "Part: 1"
sktch = "Sketch"
SketchVisible (Visible, prt, sktch)
End sub

Sub SketchVisible (Visible As Boolean, prt As String, sktch As String)
Dim compOcc = Component.InventorComponent (prt)
Dim oSk As PlanarSketch = compOcc.Definition.Sketches.Item (sktch)
Dim oSkProx As PlanarSketchProxy = Nothing
Call compOcc.CreateGeometryProxy (oSk, oSkProx)
oSkProx.Visible = Visible
End sub

Thanks!

0 Likes
Message 6 of 6

Z0methink
Enthusiast
Enthusiast

I wanted to do something like this:

 

Sub main ()

Visible = True
prt = "Part: 1"
SketchVisible (Visible, prt)

 

Visible = True
prt = "Part: 2"
SketchVisible (Visible, prt)

 

Visible = False
prt = "Part: 3"
SketchVisible (Visible, prt)

 

End sub

 

Sub SketchVisible (Visible As Boolean, prt As String)
Dim compOcc = Component.InventorComponent (prt)
Dim oSk As PlanarSketch = compOcc.Definition.Sketches.Item ("Sketch")
Dim oSkProx As PlanarSketchProxy = Nothing
Call compOcc.CreateGeometryProxy (oSk, oSkProx)
oSkProx.Visible = Visible
End sub

0 Likes