- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
We try to place a sketch with a Custom Propertie on a planar face of all appearances in an assembly. Each appearance has an unique Description and in this case we want to see them in the assembly.
I have write the following iLogic code: (The error message is below)
Does anyone know what I'm doing wrong?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
You didn't include any declaration or assignment to the variable named oOccurrence. Can you post your complete rule as a text file?

Mike Deck
Software Developer
Autodesk, Inc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Below modification may be helpful in creating sketch after selection of face.
Dim oFace As Face
oFace = ThisApplication.CommandManager.Pick(kPartFacePlanarFilter, "Select a face")
Dim occ As ComponentOccurrence
occ = oFace.ContainingOccurrence
Dim oFaceProxy As FaceProxy
Call occ.CreateGeometryProxy(oFace, oFaceProxy)
If oFaceProxy.SurfaceType = kPlaneSurface Then
oSketch = oAssDef.Sketches.Add(oFaceProxy)
End If
Thanks and regards,
CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Dim comp As Object
Dim oAssDoc As Object
comp = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Selecteer een component")
oAssDoc = comp
If TypeOf oOccurrence Is ComponentOccurrenceProxy Then
Prop = iProperties.Value(oAssDoc.NativeObject.Name, "Project", "Description")
Else
Prop = iProperties.Value(oAssDoc.Name, "Project", "Description")
End If
Dim oAssDef As AssemblyComponentDefinition = oAssDoc.Definition
Dim oFace As Face
oFace = ThisApplication.CommandManager.Pick (SelectionFilterEnum.kAllPlanarEntities,"Selecteer een vlak")
' make sure it Is a planar face
If oFace.SurfaceType = SurfaceTypeEnum.kPlaneSurface Then
oPlanarSurface = oFace.Geometry
'add a sketch
oSketch = oAssDef.Sketches.Add(oFace)
'trying to choose an appropriate point
'assume this planar face has one edge loop only
oEdgeLoop = oFace.EdgeLoops(1)
oMinPt = oEdgeLoop.RangeBox.MinPoint
oMaxPt = oEdgeLoop.RangeBox.MaxPoint
CenterPt = oAssDef.TransientGeometry.CreatePoint((oMaxPt.X + oMinPt.X) / 2#, (oMaxPt.Y + oMinPt.Y) / 2#, (oMaxPt.Z + oMinPt.Z) / 2#)
'get one point on the face and transform to the point2d on the sketch
'oTextPt = oSketch.ModelToSketchSpace(oPlanarSurface.RootPoint)
oTextPt = oSketch.ModelToSketchSpace(CenterPt)
'add the textbox
oSketchText = oSketch.TextBoxes.AddFitted(oTextPt, "<StyleOverride FontSize='30'>" & Prop & "</StyleOverride>")
Else
MsgBox( "Selecteer een vlak, en geen ronding, aub!")
End If
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
This modification doesn't fix my problem.
The same error message continues to appear.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Can you please answer below questions?
- iProperty value of "Description" is taken from Top assembly or Selected occurrence?
- Sketch is created in Top assembly or selected occurrence?
- Selected occurrence is assembly document or part document?
It's very confusion in coding.
Thanks and regards,
CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Sorry for confusing you.
I still have to gain experience in programming..
1. From selected occurrence
2. Created in Top assembly
3. Selected occurrence can be both part of assy.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Try below iLogic code.
Dim comp As ComponentOccurrence
comp = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Selecteer een component")
If TypeOf oOccurrence Is ComponentOccurrenceProxy Then
Prop = iProperties.Value(comp.NativeObject.Name, "Project", "Description")
Else
Prop = iProperties.Value(comp.Name, "Project", "Description")
End If
Dim oAssDef As AssemblyComponentDefinition = ThisDoc.Document.ComponentDefinition
Dim oFace As Face
oFace = ThisApplication.CommandManager.Pick (SelectionFilterEnum.kAllPlanarEntities,"Selecteer een vlak")
' make sure it Is a planar face
If oFace.SurfaceType = SurfaceTypeEnum.kPlaneSurface Then
Dim oFaceProxy As FaceProxy
comp.CreateGeometryProxy(oFace, oFaceProxy)
oPlanarSurface = oFace.Geometry
'add a sketch
oSketch = oAssDef.Sketches.Add(oFaceProxy)
'trying to choose an appropriate point
'assume this planar face has one edge loop only
oEdgeLoop = oFaceProxy.EdgeLoops(1)
oMinPt = oEdgeLoop.RangeBox.MinPoint
oMaxPt = oEdgeLoop.RangeBox.MaxPoint
CenterPt = ThisApplication.TransientGeometry.CreatePoint((oMaxPt.X + oMinPt.X) / 2#, (oMaxPt.Y + oMinPt.Y) / 2#, (oMaxPt.Z + oMinPt.Z) / 2#)
'get one point on the face and transform to the point2d on the sketch
'oTextPt = oSketch.ModelToSketchSpace(oPlanarSurface.RootPoint)
oTextPt = oSketch.ModelToSketchSpace(CenterPt)
'add the textbox
oSketchText = oSketch.TextBoxes.AddFitted(oTextPt, "<StyleOverride FontSize='30'>" & Prop & "</StyleOverride>")
Else
MsgBox( "Selecteer een vlak, en geen ronding, aub!")
End If
Thanks and regards,
CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report