<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Inventor iLogic &amp;quot;The Parameter is Incorrect&amp;quot; Exception Not Making Sense in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-ilogic-quot-the-parameter-is-incorrect-quot-exception/m-p/12743638#M10709</link>
    <description>&lt;P&gt;I think the problem is when you click the edge in an assembly environment the edge is a proxy; it's not the real part edge.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;add this after you select the edge&lt;/P&gt;&lt;PRE&gt;	&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;selectedEdge&lt;/SPAN&gt;.&lt;SPAN&gt;Type&lt;/SPAN&gt; = &lt;SPAN&gt;kEdgeProxyObject&lt;/SPAN&gt;
		&lt;SPAN&gt;selectedEdge&lt;/SPAN&gt; = &lt;SPAN&gt;selectedEdge&lt;/SPAN&gt;.&lt;SPAN&gt;NativeObject&lt;/SPAN&gt;
	&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 30 Apr 2024 13:50:24 GMT</pubDate>
    <dc:creator>daltonNYAW9</dc:creator>
    <dc:date>2024-04-30T13:50:24Z</dc:date>
    <item>
      <title>Inventor iLogic "The Parameter is Incorrect" Exception Not Making Sense</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-ilogic-quot-the-parameter-is-incorrect-quot-exception/m-p/12743408#M10708</link>
      <description>&lt;P&gt;Looking for input from any Inventor iLogic gurus out there...&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;INTENT:&lt;/STRONG&gt; I've written an external iLogic rule that runs when the user clicks on a macro button within an .ipt environment. The intent is to (in 2 clicks) model the path our routers take when we don't want a radiused inside corner. We have always had to draw this manually but it takes about 30-40 seconds, whereas now it takes 3 with this iLogic rule.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;LOGIC&lt;/STRONG&gt;: When the user clicks on the macro button, they are prompted to select a model edge (selection filtered only for edges). When selected, the edge length data is collected and a workpoint is added at the midpoint of the edge.&amp;nbsp;&lt;BR /&gt;&lt;EM&gt;Next&lt;/EM&gt;, a workplane is added at that workpoint perpendicular to the edge.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Next&lt;/EM&gt;, a sketch is created on that workplane and the workpoint is projected.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Next&lt;/EM&gt;, a pre-created sketchblock is added to the sketch and the insert point is constrained to the projected workpoint.&lt;BR /&gt;&lt;EM&gt;Next&lt;/EM&gt;, I iterate through the sketch entities to find a circle entity and ground its center point (just to prevent the sketch from rotating).&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Then&lt;/EM&gt;, the user is prompted to select one of the 4 circle profiles in the sketch and once clicked, an extrusion feature is added symmetrically to a distance of the previously collected edge length.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That's basically it, other than a few other fluff/maintenance things like setting a parameter that tracks the number of these features that are added (for feature-naming reasons), checking if that parameter exists and adds if necessary, checking if the sketchblock exists and adding if necessary, etc...&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;ISSUE:&lt;/STRONG&gt; I had it working perfectly yesterday (both when running the rule when working on an .ipt file that was open on its own and when editing a part directly from within an assembly), however today I get an error when trying to run the rule when editing the part within an assembly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The exception is cast on line 74 when trying to make the workpoint and the error is "The parameter is incorrect". However, I've ensured that I'm passing the correct types into the method and ensured that the parent the rule is seeing is a 'Part Document' (because I know creating the work point doesn't work in an assembly).&lt;/P&gt;&lt;P&gt;I've been pulling my hair out (not literally lol) trying to figure out what's causing the exception.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Again, it used to work both while editing the part in an assembly AND with the part open on its own, but now it only works with the latter. 95% of the time we'll want to use it while editing the part within an assembly, so any help with what's causing the error would be GREATLY appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;div class="lia-vid-container video-embed-center"&gt;&lt;div id="lia-vid-6352036363112w960h540r19" class="lia-video-brightcove-player-container"&gt;&lt;video-js data-video-id="6352036363112" data-account="6057940548001" data-player="default" data-embed="default" class="vjs-fluid" controls="" data-application-id="" style="width: 100%; height: 100%;"&gt;&lt;/video-js&gt;&lt;/div&gt;&lt;script src="https://players.brightcove.net/6057940548001/default_default/index.min.js"&gt;&lt;/script&gt;&lt;script&gt;(function() {  var wrapper = document.getElementById('lia-vid-6352036363112w960h540r19');  var videoEl = wrapper ? wrapper.querySelector('video-js') : null;  if (videoEl) {     if (window.videojs) {       window.videojs(videoEl).ready(function() {         this.on('loadedmetadata', function() {           this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) {             bar.setAttribute('role', 'presentation');             bar.setAttribute('aria-hidden', 'true');           });         });       });     }  }})();&lt;/script&gt;&lt;a class="video-embed-link" href="https://forums.autodesk.com/t5/video/gallerypage/video-id/6352036363112"&gt;(view in My Videos)&lt;/a&gt;&lt;/div&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Sub Main 
	
	'Define Part environment
	Dim oPartDoc As PartDocument
	Dim oCompDef As PartComponentDefinition
	
	If TypeOf ThisDoc.Document Is PartDocument Then
		
		oPartDoc = ThisDoc.Document
		oCompDef = oPartDoc.ComponentDefinition
						
	ElseIf TypeOf ThisDoc.Document Is AssemblyDocument Then
		MessageBox.Show("This program can only be run on a PART document.", "Incorrect Filetype - Assembly",MessageBoxButtons.OK,MessageBoxIcon.Information)
	ElseIf TypeOf ThisDoc.Document Is DrawingDocument Then
		MessageBox.Show("This program can only be run on a PART document.", "Incorrect Filetype - Drawing",MessageBoxButtons.OK,MessageBoxIcon.Information)
	Else
		MessageBox.Show("Unable to determine filetype.", "Incorrect Filetype",MessageBoxButtons.OK,MessageBoxIcon.Information)
	End If	
	
	' Prompt selection of the edge to work with
	Dim selectedEdge As Edge = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeFilter, "Select an edge")
	
	Dim edgeLength As Double 'Holds the length of the model edge that was selected
	
	If selectedEdge IsNot Nothing Then
		
		edgeLength = ThisApplication.MeasureTools.GetMinimumDistance(selectedEdge.StartVertex, selectedEdge.StopVertex)
	Else
			MessageBox.Show("No edge selected.", "Router Path Selection Cancelled", MessageBoxButtons.OK, MessageBoxIcon.Information)
      	Exit Sub
	End If
	
		'Get access to and update a parameter that tracks the number of these extra planes and points added to create unique feature names
		Dim oUserParams As UserParameters = oCompDef.Parameters.UserParameters
		Dim currentRuns As Integer 'This is the value that is managed within this rule
		
		Dim newParam As Parameter = Nothing
		Dim defaultValue As Integer
		Dim paramName As String
			paramName = "routerPathRuns"
			
		'First check to see if it exists in this model...
		 For Each p As Parameter In oUserParams
        	
			If p.Name = paramName Then
          	  newParam = p
			  
				currentRuns = p.Value
				currentRuns += 1
				
				p.Value = currentRuns
				RuleParametersOutput()
			 Exit For ' Exit loop once parameter is found and the above has run
		 	End If
  	 	 Next
		 
		 'If the parameter doesn't exist, add it first then continue
		 If newParam Is Nothing Then
       		
			newParam = oUserParams.AddByExpression(paramName, defaultValue, UnitsTypeEnum.kUnitlessUnits)
			
			currentRuns = oUserParams.Item(paramName).Value
			currentRuns += 1
			oUserParams.Item(paramName).Value = currentRuns
			
			RuleParametersOutput()
   		 End If

	'Create a workpoint at the MidPoint of the selected line
	Dim oWorkPoint As WorkPoint

	Try
		
		oWorkPoint = oCompDef.WorkPoints.AddByMidPoint(selectedEdge, False)
	
	Catch ex As Exception
		
		MessageBox.Show("Try adding this feature while having the part opened on its own.", "Houston... We have a problem.", MessageBoxButtons.OK, MessageBoxIcon.Information)
		
		Exit Sub
	End Try
		
	Dim	workPointName As String = "Router Path MidPoint " &amp;amp; currentRuns
		oWorkPoint.Name = workPointName
		oWorkPoint.Visible = False
		
	'Create a work plane perpendicular to the selected edge's MidPoint
	Dim oWorkPlanes = oCompDef.WorkPlanes
    Dim oWorkPlane As WorkPlane
		oWorkPlane = oWorkPlanes.AddByNormalToCurve(selectedEdge, oCompDef.WorkPoints(workPointName), False)
		oWorkPlane.Name = "Router Path Plane " &amp;amp; currentRuns
		oWorkPlane.Visible = False

	'Create the sketch and add it to the new work plane
	Dim oSketch As PlanarSketch
		oSketch = oCompDef.Sketches.Add(oWorkPlane)
		oSketch.Name = "Router Path Sketch " &amp;amp; currentRuns
		
	oSketch.Edit
	
	Dim centre = oCompDef.WorkPoints.Item(workPointName)
	Dim existingCentrePoint As SketchEntity = oSketch.AddByProjectingEntity(centre)
	
	Dim oTransGeom As TransientGeometry
		oTransGeom = ThisApplication.TransientGeometry
	Dim oDef As ControlDefinition
		oDef = ThisApplication.CommandManager.ControlDefinitions.Item("SketchProjectCutEdgesCmd")
		oDef.Execute
		
	'Check if the required SketchBlock exists in the model and if not, add it.
	If oCompDef.SketchBlockDefinitions.Count = 0 Then

		Dim oSourceDoc As PartDocument 'Referene to the template .ipt
		Dim oSourceSketchBlock As SketchBlockDefinition 
			
			oSourceDoc = ThisApplication.Documents.Open("C:\Vault_Work\Templates\Standard.ipt") 'Find the template PART
			oSourceSketchBlock = oSourceDoc.ComponentDefinition.SketchBlockDefinitions.Item("Router Path") 'Get access to the SKETCH BLOCK in the template
			oSourceSketchBlock.CopyTo(oPartDoc)

			oSourceDoc.Close()
	End If
		
	'Insert the pre-created sketch block and position it
	Dim routerPathBlock As SketchBlockDefinition
		routerPathBlock = oCompDef.SketchBlockDefinitions.Item("Router Path")
	Dim oPosition As Point2d
   		oPosition = ThisApplication.TransientGeometry.CreatePoint2d(centre.Point.X, centre.Point.Z)
    Call oSketch.SketchBlocks.AddByDefinition(routerPathBlock, oPosition)
		
	Dim sketchBlockRef As SketchBlock = oSketch.SketchBlocks.Item(1)
	Dim insertRef As SketchPoint = sketchBlockRef.Definition.InsertionPoint
	Dim insertRef2 As SketchPoint = sketchBlockRef.GetObject(insertRef)
	
	oSketch.GeometricConstraints.AddCoincident(insertRef2, existingCentrePoint)
		

	'Iterate through the sketch objects to find the first reference to a circle and ground the centre point to prevent SketchBlock rotation.
	For Each sEntity As SketchEntity In oSketch.SketchEntities
		
		If sEntity.Type = ObjectTypeEnum.kSketchCircleObject Then
						
			Dim chosenCircle As SketchCircle = sEntity
			Dim chosenCircleCentre As SketchPoint = chosenCircle.CenterSketchPoint
			
				oSketch.GeometricConstraints.AddGround(chosenCircleCentre)
		Exit For
    End If
Next
	
	oSketch.ExitEdit
	
ThisApplication.ActiveView.Update()

	'Pass through the distance for the extrude
	ExtrudeProfile(edgeLength, oCompDef, oWorkPoint, oUserParams, currentRuns)
	
End Sub


'Perform the extrude of the router path
Sub ExtrudeProfile(edgeLength As Double, part As PartComponentDefinition, selectedWorkpoint As WorkPoint, forwardedUserParams1 As UserParameters, routerPathCount As Integer)
	
	'Hold the distance for the extrude
	Dim extrudeLength As Double = edgeLength
	
	'Prompt the user to select the correct profile
	Dim selectedProfile As Profile = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kSketchProfileFilter, "Select a profile")
	
	If selectedProfile IsNot Nothing Then
		
		'Extrude the selected profile to the extent of the selected edge length
		Dim extrudeDef As ExtrudeDefinition = part.Features.ExtrudeFeatures.CreateExtrudeDefinition(selectedProfile, PartFeatureOperationEnum.kCutOperation)
			extrudeDef.SetDistanceExtent(extrudeLength, PartFeatureExtentDirectionEnum.kSymmetricExtentDirection)
	
		Dim extrudeFeature As ExtrudeFeature = part.Features.ExtrudeFeatures.Add(extrudeDef)
			extrudeFeature.Name = "Router Path Extrusion " &amp;amp; routerPathCount
		
	Else
		
		'No profile selected, remove the features (Workplane, Workpoint and sketch) that were just added.
		MessageBox.Show("No profile selected.", "Router Path Selection Cancelled", MessageBoxButtons.OK, MessageBoxIcon.Information)
		
		DeleteFeatures(part, selectedWorkpoint, forwardedUserParams1)
		
      	Exit Sub
	End If
End Sub

'If extruding the router path was cancelled before completion, delete the features that were already created during setup.
Sub DeleteFeatures(thisPart As PartComponentDefinition, workPointToDelete As WorkPoint, forwardedUserParams2 As UserParameters)

	'Iterate through all the model work points to delete the one just added. It also deletes any dependent children (the new sketch plane and sketch)
	For Each modelWorkPoint As WorkPoint In thisPart.WorkPoints
		
		If modelWorkPoint.Name = workPointToDelete.Name Then
			modelWorkPoint.Delete(False)
		End If
	Next
	
	'Backtrack the routerPathRuns variable count so that it doesn't count up for the one that was just cancelled.
		Dim reverseRunCount As Integer 

			For Each oParameter In forwardedUserParams2 
				
				If oParameter.Name = "routerPathRuns"
				 
				 	reverseRunCount = oParameter.Value
					reverseRunCount -= 1
				 
					oParameter.Value = reverseRunCount
							
					RuleParametersOutput()
				Exit For
				End If
			Next
End Sub&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 30 Apr 2024 12:22:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-ilogic-quot-the-parameter-is-incorrect-quot-exception/m-p/12743408#M10708</guid>
      <dc:creator>justinS3RHN</dc:creator>
      <dc:date>2024-04-30T12:22:45Z</dc:date>
    </item>
    <item>
      <title>Re: Inventor iLogic "The Parameter is Incorrect" Exception Not Making Sense</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-ilogic-quot-the-parameter-is-incorrect-quot-exception/m-p/12743638#M10709</link>
      <description>&lt;P&gt;I think the problem is when you click the edge in an assembly environment the edge is a proxy; it's not the real part edge.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;add this after you select the edge&lt;/P&gt;&lt;PRE&gt;	&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;selectedEdge&lt;/SPAN&gt;.&lt;SPAN&gt;Type&lt;/SPAN&gt; = &lt;SPAN&gt;kEdgeProxyObject&lt;/SPAN&gt;
		&lt;SPAN&gt;selectedEdge&lt;/SPAN&gt; = &lt;SPAN&gt;selectedEdge&lt;/SPAN&gt;.&lt;SPAN&gt;NativeObject&lt;/SPAN&gt;
	&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2024 13:50:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-ilogic-quot-the-parameter-is-incorrect-quot-exception/m-p/12743638#M10709</guid>
      <dc:creator>daltonNYAW9</dc:creator>
      <dc:date>2024-04-30T13:50:24Z</dc:date>
    </item>
    <item>
      <title>Re: Inventor iLogic "The Parameter is Incorrect" Exception Not Making Sense</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-ilogic-quot-the-parameter-is-incorrect-quot-exception/m-p/12743701#M10710</link>
      <description>&lt;P&gt;Well I'll be... that's fantastic! Thanks for the tip!&lt;/P&gt;&lt;P&gt;Works beautifully now &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2024 14:05:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-ilogic-quot-the-parameter-is-incorrect-quot-exception/m-p/12743701#M10710</guid>
      <dc:creator>justinS3RHN</dc:creator>
      <dc:date>2024-04-30T14:05:26Z</dc:date>
    </item>
  </channel>
</rss>

