Hi Kris,
Thanks for the info. From the sample you posted below I can apply the types
of constraints that I want. Is it possible to apply the same constraints as
below but without user selected - using points? I can easily calculate the
points I need to select the geometry at but I can't figure out how to apply
these into the constraints. Any ideas??
Many thanks
Guy.
--
Guy Bursell
CAD Development Engineer
Mabey & Johnson Ltd.
Kris Kaplan wrote in message
news:81uagd$3bd12@adesknews2.autodesk.com...
>
> Guy,
>
> Create sketch constraints with a constraint descriptor and the
AddConstraint
> method on McadSketch. As with the AMPROFILE command, when an arc is used
as
> an operand in a distance constraint, the center is inferred, so you should
> only need to use the arc as one of the operands of the desired constraint
> type.
>
> The only trick to creating sketch constraints is that the operands are
> expected to be 'focused' to the sketch. Sketch geometry lives a kind of
> dual life, the geometry that you see (instanced in model space and
> transformed to the active instance), and the internal geometry in the part
> definition (the stuff that lives on when the sketch is consumed). When
you
> pick and highlight sketch geometry, you deal in the display geometry.
When
> you ask a sketch for it's geometry or create or query a constraint, you
deal
> with the internal sketch geometry. You can use McadUtility.RefocusObject
> with the McadSketch as the reference object to convert from the display
> geometry to the sketch geometry. At this time there is no usable refocus
> reference object, and therefore easy way, to go from sketch geometry to
> display (the display geometry comes and goes, and moves in and out of the
> part's component definition depending on the active state of the part, so
it
> isn't as useful as you would think).
>
> The example below creates a simple horizontal sketch constraint, with the
> first operand being an arc. The constraint creation automatically infers
> the center point of the arc, but if you want you could use
> McadUtility.InferGeometry or the infer options on GetGeometryFromPick to
> manually infer the center point yourself before creation (or for any other
> reason).
>
> Kris
>
>
> Sub test()
> Dim mcad As McadApplication
> Set mcad =
> ThisDrawing.Application.GetInterfaceObject("Mcad.Application")
> Dim ge As GeApplication
> Set ge = ThisDrawing.Application.GetInterfaceObject("Ge.Application")
> Dim util As McadUtility
> Set util = mcad.ActiveDocument.Utility
>
> ' pick an arc
> Dim pick As McadPick
> Set pick = util.pick("Select sketch arc", mcArc)
> Dim arc As McadArc
> Set arc = util.GetObjectFromPick(pick)
>
> ' reuse the pick to locate the sketch
> ' (will fail if didn't select sketch arc)
> Dim sketch As McadSketch
> pick.ObjectType = mcSketch
> Set sketch = util.GetObjectFromPick(pick)
>
> ' refocus to get the arc in the sketch (not the display)
> util.RefocusObject arc, sketch
>
> ' select another point on the sketch (should ckeck for 'same' sketch)
> Set pick = util.pick("H distance from center to", mcPoint)
> Dim point As McadPoint
> Set point = util.GetGeometryFromPick(mcPoint, True, pick)
> util.RefocusObject point, sketch
>
> ' get the dimension display location
> Dim gePt As GePoint
> Set gePt = ge.point
> gePt.AsArray = ThisDrawing.Utility.GetPoint(, "dimension location: ")
>
> ' create the constraint
> Dim desc As McadConstraintDescriptor
> Set desc = util.CreateConstraintDescriptor(mcSkHorizontalDistance)
> desc.Displayed = True
> desc.Operand1 = arc
> desc.Operand2 = point
> desc.DisplayLocation = gePt
> Dim length As McadValue
> Set length = util.CreateValue
> length = ThisDrawing.Utility.GetDistance(, "Length: ")
> desc.Value = length
> sketch.AddConstraint desc
> End Sub
>
> Guy Bursell wrote in message <81iu0s$ctc8@adesknews2.autodesk.com>...
> >Hi,
> >
> >Does anyone know how I can apply sketch constraints to an arc in a sketch
> in
> >MCAD VBA? More specifically, I'm trying to find the centre point of the
> >arc. I've tried to do this simply in Acad 2000, to select an arc and
place
> >a dimension showing the radius but haven't had any luck.
> >
> >Thanks
> >
> >Guy
> >
>
>
>