- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Everyone.
I'm trying to write a code which adds a workplane in a assembly.
I can add the workplane but can only use a Double for the offset. (I would like to use a string which references some user parameters.
So my idea was to place the Workplane using Ilogic and change the offset afterwards in the same code and then use the string value.
The Code I'm using to place the Workplane is this:
Sub AddPlanes'Check and add Mid and Back plane if needed oDef = ThisDoc.Document.ComponentDefinition Dim pOffsetRightplane As String = "pCcLength / 2" Dim pOffsetLeftplane As String = "-pCcLength / 2" Dim oWPlaneRight As WorkPlane Dim oWPlaneLeft As WorkPlane oWPlaneRight = AddWorkPlaneInAssemblyOffset(oDef.WorkPlanes("XZ Plane (Right)"), 1) oWPlaneRight.Name = "CC Right" oWPlaneRight = AddWorkPlaneInAssemblyOffset(oDef.WorkPlanes("XZ Plane (Right)"), -1) oWPlaneRight.Name = "CC Left" oWPlaneRight.Offset.Expression = pOffsetRightplane oWPlaneLeft.OffseI'm t.Expression = pOffsetLeftplane End Sub Function AddWorkPlaneInAssemblyOffset(oFace As Object, oOffset As Double) As WorkPlane Dim uOM As UnitsOfMeasure = ThisDoc.Document.UnitsOfMeasure Dim oAsm As AssemblyDocument = ThisApplication.ActiveDocument Dim oDef As AssemblyComponentDefinition = oAsm.ComponentDefinition Dim oOriginPnt As Point Dim oXaxis As UnitVector Dim oYaxis As UnitVector oOriginPnt = ThisApplication.TransientGeometry.CreatePoint(0#, 0#, 0#) oXaxis = ThisApplication.TransientGeometry.CreateUnitVector(1#, 0#, 0#) oYaxis = ThisApplication.TransientGeometry.CreateUnitVector(0#, 1#, 0#) Dim oPlane As WorkPlane = oDef.WorkPlanes.AddFixed(oOriginPnt, oXaxis, oYaxis) oPlane.AutoResize = True oDef.Constraints.AddFlushConstraint(oFace, oPlane, uOM.ConvertUnits(oOffset, uOM.LengthUnits, UnitsTypeEnum.kDatabaseLengthUnits)) oPlane.AutoResize = False Return oPlane End Function
This is the Code which should change the existing offset to my string value but it doesn't work.
oWPlaneRight.Offset.Expression = pOffsetRightplane oWPlaneLeft.Offset.Expression = pOffsetLeftplane
I'm getting this error.
Error on line 50 in rule: CCLength for rails, in document: CAD0006625.iam
Public member 'Offset' on type 'WorkPlane' not found.
I've underlined Line 50.
Can anyone help me with changing the existing value to a string value?
Br
Justin
Solved! Go to Solution.