Sketch creation flips Coordinate System

Sketch creation flips Coordinate System

They_Call_Me_Jake
Advocate Advocate
405 Views
3 Replies
Message 1 of 4

Sketch creation flips Coordinate System

They_Call_Me_Jake
Advocate
Advocate

I am trying to write some iLogic that will create a sketch based on some user input and insert a circle (and eventually a linear pattern of said circle) but when I try to specify the point at which I want the circle to be placed it flips the coordinate system and places the circle outside of the part. I've searched and cannot seem to find how to fix this issue. Here is the code I have, please be gentle....I am not a programmer so I am fumbling thru while trying to learn.

Dim oPartDoc As Document = ThisDoc.Document
Dim oPartCompDef As PartComponentDefinition = ThisApplication.ActiveDocument.ComponentDefinition
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry

'get measurements to determine Material Thickness
My_x = Measure.ExtentsLength
My_y = Measure.ExtentsWidth
My_z = Measure.ExtentsHeight

'Make longest value the Length, rounded to 2 places
Thickness = Round(MinOfMany(My_x, My_y, My_z), 4)

If oPartDoc.DocumentType = kPartDocumentObject Then
		
Dim oParams As Parameters = oPartCompDef.Parameters
				
		Dim oUserParams As UserParameters = oParams.UserParameters               
				
		Try
			oHoleSizes = oUserParams.Item("HoleSizes")
			Catch
oInsulationType = oUserParams.AddByValue("HoleSizes", 0, kInchLengthUnits) 
MultiValue.SetList("HoleSizes", .109375, .125, .15625, .1875, .21875, .28125)
			End Try
			
		Try
			oMaterial = oUserParams.Item("Material")
			Catch
oInsulationType = oUserParams.AddByValue("Material", " ", kTextUnits) 
MultiValue.SetList("Material", "Starboard", "Acrylic", "Proboard")
			End Try
						
		Try
			oHoleType = oUserParams.Item("HoleType")
			Catch
oInsulationType = oUserParams.AddByValue("HoleType", " ", kTextUnits) 
MultiValue.SetList("HoleType", "Pilot", "Thru", "Custom")
			End Try
			End If

Parameter.Param("HoleSizes").ExposedAsProperty = False
Parameter.Param("HoleSizes").IsKey = True
Parameter.Param("Material").ExposedAsProperty = False
Parameter.Param("Material").IsKey = True
Parameter.Param("HoleType").ExposedAsProperty = False
Parameter.Param("HoleType").IsKey = True

Dim oFace As Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select Surface to Place Holes")
Dim oFrontEdge As Edge = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeFilter, "Select Front Edge of Pattern")
Dim oVertex As Vertex = oFrontEdge.StartVertex

Dim oLeftEdge As Edge = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeFilter, "Select Left Edge of Pattern")
Dim oRightEdge As Edge = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeFilter, "Select Right Edge of Pattern")
oMaterial = InputListBox("Select Material", MultiValue.List("Material"), DrillSizes, Title := "Title", ListName := "List")
oHoleSize = InputListBox("Select Hole Type", MultiValue.List("HoleType"), DrillSizes, Title := "Title", ListName := "List")
oHoleSize = InputListBox("Select Hole Size", MultiValue.List("HoleSizes"), DrillSizes, Title := "Title", ListName := "List")

Dim oSketch As PlanarSketch
oSketch = oPartCompDef.Sketches.AddWithOrientation(oFace, oFrontEdge, True, True, oVertex, False)
oSketch.Name = "My Oriented Sketch"

Dim oCircle As SketchCircle = oSketch.SketchCircles.AddByCenterRadius(oTG.CreatePoint2d(.1, .1), (oHoleSize/2))

 

0 Likes
406 Views
3 Replies
Replies (3)
Message 2 of 4

TobFischer94
Enthusiast
Enthusiast

i dont know, but maybe the problem lies within the fact that a sketch on a plane can be created from both "sides" of the plane, facing opposite directions. Maybe the "side" of the plane on which the sketch shall be created has to be further identified.

0 Likes
Message 3 of 4

chandra.shekar.g
Autodesk Support
Autodesk Support

@They_Call_Me_Jake,

 

It all depends on selection of edges and coordinate of circle center point.

 

For Example, check the location of circle and selection of edges in below image.

 

Coordinate.png

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 4 of 4

They_Call_Me_Jake
Advocate
Advocate

@chandra.shekar.g I see what you mean that it depends on the selection of edges. What I am trying to accomplish is to have the user select the face that the sketch will be placed on and then select the "Front Edge" that the pattern of holes would be parallel to and then the "Left Edge" that would be the start of the pattern. The problem I run into is that we could potentially have a linear pattern of holes on multiple edges of a shape each in their own sketch. So as the user goes along and selects the face and two edges for each linear pattern of holes in each sketch I would like the coordinate system for each sketch to be oriented at the point where the "Left Edge" and "Front Edge" in the current sketch  meet and the "X" Axis be along the Front edge and in the direction from left to right as depicted in the picture below. Is there any way to accomplish this?Hole Pattern Creation.jpg

0 Likes