Create ucs vb.net in sheet metal flatpattern

Create ucs vb.net in sheet metal flatpattern

vishnuteja14
Contributor Contributor
213 Views
1 Reply
Message 1 of 2

Create ucs vb.net in sheet metal flatpattern

vishnuteja14
Contributor
Contributor
  1. Hi all I am trying to create ucs in flat plattern of a sheet metal part using vb.net I can pick origin point as work point and now am having trouble on how to proceed with code to add ucs using vb.net 
  2. Can any one help me with this 
0 Likes
214 Views
1 Reply
Reply (1)
Message 2 of 2

WCrihfield
Mentor
Mentor

Hi @vishnuteja14.  I am curious, why would you want to create a UCS within the flat pattern of a sheet metal part?  That UCS will most likely only exist while that 'edit mode' is active, and not while in 'folded edit mode'.  Also, there are two different ways to define a UCS.  One way is by specifying 3 points...one will be the new origin of that UCS, one will be a point in the X-direction from that new origin point, and one will be in the Y-direction from that new origin point.  The other way is by specifying its transformation, which wants us to supply an Inventor.Matrix object, which defines its location, rotation, and orientation in 3D space.  So, which way were you planning on using?

A single WorkPoint only defines a single point in 3D space, but does not define any rotation or orientation of axes/planes.  Plus, a WorkPoint that was defined while in 'folded editing mode' may not be accessible while in 'flat pattern editing mode', so there is that.

A common misunderstanding in these types of situations is that the 'FlatPattern' object is its own 'ComponentDefinition', so it has its own coordinate space, its own separate collection of Parameters, its own separate collection of features, and so on.

Sometimes we may be able to 'transform' an object from one space/context to the other space/context using a special method (links below), but I don't recall if those work on WorkPoint type objects.

FlatPattern.GetFlatPatternEntity 

FlatPattern.GetSheetMetalEntity 

Below is a 'starter' iLogic rule that you can look at, but it is not complete, because I don't have all the information needed.

Sub Main
	Dim oPDoc As PartDocument = TryCast(ThisDoc.Document, Inventor.PartDocument)
	If oPDoc Is Nothing Then
		Logger.Debug(iLogicVb.RuleName & " exited because no PartDocument was obtained!")
		Return
	End If
	If Not TypeOf oPDoc.ComponentDefinition Is SheetMetalComponentDefinition Then
		Logger.Debug(iLogicVb.RuleName & " exited because the part was not Sheet Metal!")
		Return
	End If
	Dim oSMDef As SheetMetalComponentDefinition = oPDoc.ComponentDefinition
	Dim oSMFeats As SheetMetalFeatures = oSMDef.Features
	Dim oFP As FlatPattern = Nothing
	If oSMDef.HasFlatPattern Then oFP = oSMDef.FlatPattern
	If oFP Is Nothing Then Return
	oFP.Edit()
	Dim oFP_UCSs As UserCoordinateSystems = oFP.UserCoordinateSystems
	Dim oFP_UCS_Def As UserCoordinateSystemDefinition = oFP_UCSs.CreateDefinition()
	'define by 3 points (new origin point, point in X-direction from it, and point in Y-direction)
	Dim oUCS_Origin 'WorkPoint, Vertex, SketchPoint, SketchPoint3D, or Edge (center point of edge)
	Dim oXDirectionPt 'WorkPoint, Vertex, SketchPoint, SketchPoint3D, or Edge (center point of edge)
	Dim oYDirectionPt 'WorkPoint, Vertex, SketchPoint, SketchPoint3D, or Edge (center point of edge)
	oFP_UCS_Def.SetByThreePoints(oUCS_Origin, oXDirectionPt, oYDirectionPt)
	'or, define by transformation (an Inventor.Matrix object)
	'Dim oUCS_Matrix As Inventor.Matrix 'either create a new one, or get an existing one
	'oFP_UCS_Def.Transformation = oUCS_Matrix 'an Inventor.Matrix object
	Dim oFP_UCS As UserCoordinateSystem = oFP_UCSs.Add(oFP_UCS_Def)
	oFP.ExitEdit()
	oPDoc.Update2(True)
End Sub

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

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes