Hello,
i have a few general questions about iLogic and Inventor.
1. Every line or radius i draw gets some parameters, but does inventor now to which line they belong? So is there a designation for each line or radius in the sketch?
2. If yes, can i work with them? Like Line_1 is 2000mm long and starts at x/y/z. Or Radius_1 has a radius 1000mm and is 90deg. Starts at...
3. How can i say with iLogic "Put Workingpoint "Start" from Part XY connected to Point XY in the Assembly?
The task is to draw a sketch with lines and radii and let Inventor place parts on these. Like a chain which has different parts in the straight and curved parts of it. The extended task is to have different parts in different radii.
Regards
Hi,
I suggest you to start with the Programming/API help in Inventor. You will find detailed information about how sketches work.
It's a good starting point.
Best regards
So i have read it. I found this:
Dim oCoord1 As Point2d Set oCoord1 = oTransGeom.CreatePoint2d(0, 0) Dim oCoord2 As Point2d Set oCoord2 = oTransGeom.CreatePoint2d(5, 0) Dim oLines(1 To 4) As SketchLine Set oLines(1) = oSketch.SketchLines.AddByTwoPoints(oCoord1, oCoord2)
This creates a line between two points in a sketch.
But i need it the other way around. The user creates a line and i have to work with the line parameters.
Then it is much easier.
Each dimension you use to size your sketch is automatically given a parameter name and added to the parameter tab.
In your iLogic rule you can set the value of the parameters to the value you want just writing:
d0 = <new d0 value>
d1 = < new d1 value>
Best regards
I know. But thats not enought. It makes no difference between a Arc and a Line.
The parameters in need are:
What is it? Arc or Line?
StartPoint (XYZ)
EndPoint(XYZ)
If Arc, Radius?
I need to place components on the first line from StartPoint to the EndPoint. And other Parts from Arc StartPoint to Arc EntPoint.
Hi mk92.
I don't think anyones going to write all your code for you. Generally you'll need to refer to the API help and other forum articles, get some code together and then if you can't get it to work, post it on the forum for assistance.
The article below isn't exactly what you want, but the iLogic code shows looping through the first sketch in the active part, and accesses the length property of each sketch entity (SketchLine, SketchArc, SketchCircle objects etc.) using SketchLine.Length for instance. Each of these objects also has an EndPoint and a StartPoint property, in addition to many others, which should get you towards your end goal.
Good luck
Luke
Thanks a lot! Thats the hint i needed.
I dont want anyone to write it for me!!! By no means.
You're welcome. Mark my response as the solution to help others find it. And giving people kudos is always a nice way to thank them for donating their time.
I have come forward but i need help with an error. The lenght of each SketchLine is shown correctly, but the ForEach for the Start and End Points causes an error. "Object variable or With block variable not set" Any help?
Dim oSketch As PlanarSketch oSketch = ThisApplication.ActiveEditObject Dim oSketchEnt As SketchEntity Dim StartX As Double = 0 Dim StartY As Double = 0 Dim EndX As Double = 0 Dim EndY As Double = 0 For Each oSketchEntity In oSketch.SketchEntities StartX = oSketchEnt.StartSketchPoint.Geometry.X StartY = oSketchEnt.StartSketchPoint.Geometry.Y EndX = oSketchEnt.EndSketchPoint.Geometry.X EndY = oSketchEnt.EndSketchPoint.Geometry.Y Next Dim oSketchLines As SketchLines = oSketch.SketchLines Dim oSketchLine As SketchLine Dim LineLength As Double = 0 For Each oSketchLine In oSketchLines LineLength = LineLength + oSketchLine.Length*10 MessageBox.Show(LineLength) LineLength = 0 Next
Change
For Each oSketchEntity In oSketch.SketchEntities
To:
For Each oSketchEnt In oSketch.SketchEntities
That might do it.
Nice work
Luke
Thanks! Got it a little bit different. Exactly after i have postet my question here. I did the Start and Endpoint thing in the ForEach Together with the lenght, so I can differentiate between arcs and lines.
Is it possibly to do this:
Dim oAssDoc As AssemblyDocument oAssDoc = ThisApplication.ActiveDocument Dim oAsmCompDef As AssemblyComponentDefinition oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition Dim oSketch As PlanarSketch oSketch = oAsmCompDef.Sketches.Item("Sketch 2")
With a sketch in a part from an Assembly? Sketch 2 is in a part wich is built in an assembly. So i need to set the oSketch to Sketch 2 in this part.