- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I've tried to use "sketch.redefine" syntax according to steps pre described here:
but It doesn't work and I don't know why.
Below the snippet of code I've made:
SyntaxEditor Code Snippet
Dim oDoc As PartDocument oDoc = ThisDoc.Document Dim oDef As PartComponentDefinition oDef = oDoc.ComponentDefinition Dim oSketch As PlanarSketch oSketch = oDef.Sketches.Item(1) Sketch.Redefine(oSketch.Name,"P�aszczyzna XY","Punkt �rodkowy","X",AxisIsX := True,NaturalAxisDirection:= True)
The idea is to check and redefine existing sketch on the XY plane.
Thanks in advance for any help.
Tomek
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Sketch.Redefine(oSketch.Name,"P�aszczyzna XY","Punkt �rodkowy","X", True, True)
I'm guessing the the last two inputs are optional and only need the boolean value. That's just a guess though.
Mass Override for Each Model State
Custom Glyph Icon for iMates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
hi,
did you try to redefine manually? and are sketch still healthy? if no, code will still throw a error.
Autodesk Inventor Professional Certified 2014
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
It doesn't throw any error and that is strange. I run the rule and just nothing happens.
I'm not sure If I understood the code well, could anybody let me know how originName and planeName should be defined? Specialy I'm not sure about the originName.
Thanks for any help.
Regards
Tomek
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
can you share you file?
Autodesk Inventor Professional Certified 2014
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Attached You'll find the file with rule within.
My idea was to create the rule which will check if first sketch was made on XY Plane and if wasn't to redefine sketch on XY Plane automatically.
Tomek
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
try this:
Dim oApp As Application
Dim oPD As PartDocument
Dim oPCD As PartComponentDefinition
Dim oSkt As Sketch
Dim oXY As WorkPlane
oApp = ThisApplication
oPD = oApp.ActiveDocument
oPCD = oPD.ComponentDefinition
oXY = oPCD.WorkPlanes.Item("XY Plane")
oSkt = oPCD.Sketches.Item("Szkic2")
If oSkt.PlanarEntity Is oXY Then
Else
oSkt.PlanarEntity = oXY
End If
Autodesk Inventor Professional Certified 2014
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Update for make you first sketch full constraints
Dim oApp As Application
Dim oPD As PartDocument
Dim oPCD As PartComponentDefinition
Dim oSkt As Sketch
Dim oXY As WorkPlane
Dim oCentP As WorkPoint
Dim oSktPt As SketchPoint
oApp = ThisApplication
oPD = oApp.ActiveDocument
oPCD = oPD.ComponentDefinition
oXY = oPCD.WorkPlanes.Item("XY Plane")
oCentP = oPCD.WorkPoints.Item(1)
oSkt = oPCD.Sketches.Item("Szkic2")
If Not oSkt.PlanarEntity Is oXY Then
oSkt.PlanarEntity = oXY
End If
Set oSktPt = oSkt.SketchPoints.Item(1)
On Error Resume Next
Call oSkt.AddByProjectingEntity(oCentP)
Autodesk Inventor Professional Certified 2014
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
strange,
showing some error?
my code work well
Autodesk Inventor Professional Certified 2014
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Autodesk Inventor Professional Certified 2014
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Ok, now I can see the problem. U've used direct vba syntax. I need to adjust the code for direct iLogic syntax.
Is there any simple way to do this? I've tried like this:
SyntaxEditor Code Snippet
Dim oPD As PartDocument Dim oPCD As PartComponentDefinition Dim oSkt As Sketch Dim oXY As WorkPlane Dim oCentP As WorkPoint Dim oSktPt As SketchPoint oPD = ThisApplication.ActiveDocument oPCD = oPD.ComponentDefinition oXY = oPCD.WorkPlanes.Item("XY Plane") oCentP = oPCD.WorkPoints.Item(1) oSkt = oPCD.Sketches.Item("Szkic2") If Not oSkt.PlanarEntity Is oXY Then oSkt.PlanarEntity = oXY End If oSktPt = oSkt.SketchPoints.Item(1) On Error Resume Next 'Call oSkt.AddByProjectingEntity(oCentP)
but it gives me an error at the end.
I'd like to implement the code into a bigger iLogic rule.
Tomek
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Dim oPD As PartDocument
Dim oPCD As PartComponentDefinition
Dim oSkt As PlanarSketch '<------
Dim oXY As WorkPlane
Dim oCentP As WorkPoint
Dim oSktPt As SketchPoint
oPD = ThisApplication.ActiveDocument
oPCD = oPD.ComponentDefinition
oXY = oPCD.WorkPlanes.Item("XY Plane")
oCentP = oPCD.WorkPoints.Item(1)
oSkt = oPCD.Sketches.Item("Szkic2")
If Not oSkt.PlanarEntity Is oXY Then
oSkt.PlanarEntity = oXY
End If
oSktPt = oSkt.SketchPoints.Item(1)
On Error Resume Next
Call oSkt.AddByProjectingEntity(oCentP)"PlanarEntity" isn't a member of 'Sketch' but is a member of 'PlanarSketch' which is derived from 'Sketch'.
Mass Override for Each Model State
Custom Glyph Icon for iMates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I don't know about that. maybe still member of Sketch but Hidden? because when I use VBA local window, it show in tree, but not show in quick suggestion member.
Autodesk Inventor Professional Certified 2014
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I am trying to achieve something similar but using geometry names?
I need to dynamically redefine a sketch because if my user is changing the shape of the part, the face where the sketch is assigned to disappear. Is it possible to assign a name to that face, and a name to the other face I want to use, and redefine a sketch with those names using a condition?
I've tried the code above by modifying it to what I thought would work, no success there. Is what I want to achieve completely far-fetched?
Thanks