Create Sketch

Create Sketch

Cosmin_V
Advocate Advocate
558 Views
3 Replies
Message 1 of 4

Create Sketch

Cosmin_V
Advocate
Advocate

Hello,

 

I have this rule, which it works almost fine, maybe somebody can help me to make it work good.
-We use the inventor auto naming/numbering
-If I use whatever iProperties which is contain the part name whic is "00303076" in the sketch it is not appear the leading zeros. only "303076" . Can this be fixed?

And can the sketch somehow be position on the mouse pointer position?

This is my rule....

 

  Dim pick = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFacePlanarFilter, "Select face")
    Dim face As Face = pick
	

    Dim faceBox = face.Evaluator.RangeBox
    Dim x As Double = faceBox.MaxPoint.X - faceBox.MinPoint.X
	
    x =  ThisDoc.FileName(False)

    Dim partDef As PartComponentDefinition = face.Parent.Parent
    Dim planarSketch = partDef.Sketches.Add(face)

    'Projected center of mass
   Dim position As Point2d = planarSketch.ModelToSketchSpace(partDef.MassProperties.CenterOfMass)
    
    planarSketch.TextBoxes.AddFitted(position, String.Format("{0}", x))
planarSketch.Name = "My_Sketch"

 

Many Thanks!

 

0 Likes
Accepted solutions (1)
559 Views
3 Replies
Replies (3)
Message 2 of 4

Michael.Navara
Advisor
Advisor
Accepted solution

This two lines are not correct. You define x as double, but you try to set string to it.

Comment the first line and modify the second one.

 

'Dim x As Double = faceBox.MaxPoint.X - faceBox.MinPoint.X
Dim x =  ThisDoc.FileName(False)

 

line

 

0 Likes
Message 3 of 4

Cosmin_V
Advocate
Advocate

thanks @Michael.Navara 

 

That works!

Now the sketch position...to the mouse pointer...it is that possible?

 

   Dim position As Point2d = planarSketch.ModelToSketchSpace(partDef.MassProperties.CenterOfMass)
0 Likes
Message 4 of 4

Michael.Navara
Advisor
Advisor

Is it possible, but it is not easy. You can't use the simple Pick function, but you need to implement whole  SelectEvents.OnSelect Event functionality.

0 Likes