- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to create either an iLogic Rule or a VBA Macro that when the Macro/Rule is run the user needs to select a vertex on the part and the iLogic code will take the X, Y and Z coordinates from that vertex selection and create a WorkPoint at that location. I am using the CommandManager.Pick to have the user select the vertex but when I try to add a WorkPoint using the Measure.MinimumDistance I get an error that there is an Object required. I am not a programmer so I am trying to fumble my way thru to get this to work. Is there anyone that would be able to look at the code I have and tell me what I have done wrong. Any help would be greatly appreciated.
Sub Single_Bend_Door_Add_WorkPoints() Dim oDoc As PartDocument Set oDoc = ThisApplication.ActiveDocument Dim oDef As PartComponentDefinition Set oDef = oDoc.ComponentDefinition Dim oPoint As Vertex Set oPoint = ThisApplication.CommandManager.Pick(kPartVertexFilter, "Right Side") Dim wp1 As WorkPoint Set wp1 = oDef.WorkPoints.AddByPoint(Measure.MinimumDistance(oPoint.Point.X, oPoint.Point.Y, oPoint.Point.Z)) End Sub
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
try this as an iLogic rule
SyntaxEditor Code Snippet
Dim oDoc As PartDocument oDoc = ThisApplication.ActiveDocument Dim oDef As PartComponentDefinition oDef = oDoc.ComponentDefinition Dim oPoint = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartVertexFilter, "Right Side") oDef.WorkPoints.AddByPoint(oPoint)
Hope it helps ![]()
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Change to code a little:
Sub Single_Bend_Door_Add_WorkPoints() Dim oDoc As PartDocument Set oDoc = ThisApplication.ActiveDocument Dim oDef As PartComponentDefinition Set oDef = oDoc.ComponentDefinition Dim oPoint As Vertex Set oPoint = ThisApplication.CommandManager.Pick(kPartVertexFilter, "Right Side") Dim wp1 As WorkPoint Set wp1 = oDef.WorkPoints.AddByPoint(oPoint) End Sub
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Both of those work exactly as I was wanting them too. Thank you very much. Now to figure out how to change the name of the new WorkPoint.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I figured out out how to rename my WorkPoints but another issue I am trying to work thru is how to differentiate between a Vertex of a solid and the point of a sketch. I can Change the kAllPartVertexFilter to kAllPointEntities so that I can now select the point of a sketch but that disables the ability to select a Vertex. How would I be able to select either a sketch point or a Vertex.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I was able to get what I needed from the code you helped with. I have a similar situation where I need to have the user select 4 points on a door, Upper and Lower, Left and Right Vertices but this time it's in an assembly I tried my hand at code once more but I've hit a stumbling block with the Object problem again. Here is the code I have so Far. This Time it's in ilogic. If there is a way of doing this without having to add the workpoints that would be great. Basically I just need to dimension from the YZ Plane to the bottom right and left points and from the top right and left points of the door to retrieve their dimension in the X axis so I can plug those numbers into a parameter that sets the length from midpoint in each direction of a secondary part. Any Help would be appreciated.
Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oAsmDef As AssemblyComponentDefinition = oAsmDoc.ComponentDefinition
oPoint = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAllEntitiesFilter, "Please Select the Front Lower Left Vertex of the Door")
Dim wp1 As WorkPoint = oAsmDef.WorkPoints.AddByPoint(oPoint)
wp1.Name = "wpt1"
oPoint = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAllEntitiesFilter, "Please Select the Front Lower Right Vertex of the Door")
Dim wp2 As WorkPoint = oAsmDef.WorkPoints.AddByPoint(oPoint)
wp2.Name = "wpt1"
oPoint = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAllEntitiesFilter, "Please Select the Upper Left Vertex of the Door")
Dim wp3 As WorkPoint = oAsmDef.WorkPoints.AddByPoint(oPoint)
wp3.Name = "wpt1"
oPoint = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAllEntitiesFilter, "Please Select the Upper Right Vertex of the Door")
Dim wp4 As WorkPoint = oAsmDef.WorkPoints.AddByPoint(oPoint)
wp4.Name = "wpt1"
LowerTrainLeftDim = Measure.MinimumDistance("wpt1", "YZ Plane")
LowerTrainRightDim = Measure.MinimumDistance("wpt2", "YZ Plane")
UpperTrainLeftDim = Measure.MinimumDistance("wpt3", "YZ Plane")
UpperTrainRightDim = Measure.MinimumDistance("wpt4", "YZ Plane")
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
So I realized that the object I was missing was to Dim my oPoint as a Vertex but now when I run my code I get an error that it just failed without any explanation of what failed. Would somebody be able to tell me what I am doing wrong here. I have searched the forums and the only thing I was able to find was setting a Fixed WorkPoint with typed in coordinates but nothing on picking a vertex of a part in an Assembly as where I want to place the WorkPoint. Here is the Code I have.
Sub Door_Corners() Dim oAsmDoc As AssemblyDocument Set oAsmDoc = ThisApplication.ActiveDocument Dim oAsmDef As AssemblyComponentDefinition Set oAsmDef = oAsmDoc.ComponentDefinition Dim oPoint As Vertex Set oPoint = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartVertexFilter, "Please Select the Front Lower Left Vertex of the Door") Dim wp1 As WorkPoint Set wp1 = oAsmDef.WorkPoints.AddByPoint(oPoint) End Sub
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
HI,
I try to use your program in my part, it shows error as in attached image.
I have a sketch which contains the projected cuts edges, From that I need to find points & then I have to create a sketch in it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
@Anonymous When running a rule from the iLogic IDE you need to have a Main Sub and then call your other Sub from within the Main or just put your code in the Main Sub. Also the "Set" command is an invalid command in the iLogic IDE so those just need to be removed. Try this
Sub Main() Door_Corners() End Sub Sub Door_Corners() Dim oDoc As PartDocument oDoc = ThisApplication.ActiveDocument Dim oDef As PartComponentDefinition oDef = oDoc.ComponentDefinition Dim oPoint As Vertex oPoint = ThisApplication.CommandManager.Pick(kPartVertexFilter, "Right Side") Dim wp1 As WorkPoint wp1 = oDef.WorkPoints.AddByPoint(oPoint) End Sub
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
@neodd70 ,
I need to extract points (Line intersection) from the projected sketch. Pls see the attached image, In that image I have marked an area in red.
I need a program to create a closed sketch as I shown or just to identify the points to create a sketch.
BR,
Arun Rajasekaran