TurboCAD Forums

The Ultimate Resource for TurboCAD Knowledge

Register
 
Remember to do a search before you ask a question!!!

Set Reference Point
Read 3349 times
* March 18, 2010, 05:19:11 AM
Hi Everyone,
I'm trying to set the reference point of a closed bezier curve.
I ran the TCAnnotate tool on a shape where I had manually moved the reference point which gave me this:

BrushStyle: None
    BuiltIn: False
    Closed: True
    Cosmetic: False
    Deleted: False
    Editable: True
    FixCS: False
    Child Graphics: 2
    ID: 1671
    Index: 0
    Layer: 0
    LineStyle: CONTINUOUS
    Name:
    Nodes: 5
    Reference Point: -915.447330963068, 180.298769094669, 0
    RegenType: TCW30CURVE
    Root: False
    Selected: False
    Type: TCW30CURVE
    TypeByValue: 11
    Unbounded: False
    Visible: True

Extended Properties:
    Name: PenColor; Type: 3; Value: 0
    Name: PenWidth; Type: 5; Value: 0
    Name: PenWidthGeometric; Type: 2; Value: 1
    Name: PenScale; Type: 5; Value: 1
    Name: PenStyle; Type: 8; Value: CONTINUOUS
    Name: BrushColor; Type: 3; Value: -5
    Name: HatchBGColor; Type: 3; Value: -7
    Name: BrushScale; Type: 5; Value: 25.3999996185303
    Name: BrushAngle; Type: 5; Value: 0
    Name: BrushStyle; Type: 8; Value: None
    Name: BrushTransparency; Type: 2; Value: 0
    Name: BrushGFFitMode; Type: 2; Value: 3
    Name: BrushGFCenterPointMode; Type: 2; Value: 2
    Name: BrushGFFocusScale; Type: 4; Value: -1
    Name: ScaleSystem; Type: 17; Value: 2
    Name: Layer; Type: 8; Value: 0
    Name: Info; Type: 8; Value:
    Name: URL; Type: 8; Value:
    Name: HatchCross; Type: 2; Value: 0
    Name: BrushDrawMode; Type: 2; Value: 0
    Name: HatchOriginMode; Type: 2; Value: 0
    Name: HatchOriginOffsetX; Type: 5; Value: 0
    Name: HatchOriginOffsetY; Type: 5; Value: 0
    Name: DatabaseID; Type: 3; Value: 1671
    Name: Kind; Type: 3; Value: 11
    Name: Closed; Type: 2; Value: 1
    Name: Selected; Type: 2; Value: 0
    Name: RegenMethod; Type: 8; Value: TCW30CURVE
    Name: LimitVertices; Type: 3; Value: 0
    Name: Thickness; Type: 5; Value: 0
    Name: ThicknessBody; Type: 2; Value: 1
    Name: Print style; Type: 8; Value: By Layer
    Name: M_ObjectType; Type: 8; Value: Spline
    Name: M_ConvertPenColor; Type: 17; Value: 2
    Name: M_ConvertPenColor; Type: 17; Value: 2
    Name: $SPLINESEGS; Type: 2; Value: 20
    Name: $SPLFRAME; Type: 2; Value: 0
    Name: $SPLINETYPE; Type: 2; Value: 0
    Name: $SHOWCONTRPTS; Type: 2; Value: 1
    Name: $CURVESMOOTH; Type: 2; Value: 1
    Name: DEGREE; Type: 3; Value: 3
    Name: RATIONAL; Type: 17; Value: False
    Name: SPLINECLOSED; Type: 17; Value: 1
    Name: NPOINTS; Type: 3; Value: 4
    Name: NKNOTS; Type: 3; Value: 10
    Name: REALDEGREE; Type: 3; Value: 3
    Name: #[email protected]_ToolInfo Properties; Type: 8; Value: [email protected]


Vertices (5):
    0: -982.48106000227,369.31331203648,0
    1: -671.142819602666,328.16728907618,0
    2: -909.789752772407,-205.359475309044,0
    3: -1099.06145838979,283.763872641175,0
    4: -982.48106000227,369.31331203648,0


Notice the 'Reference Point' property under Basic Properties.
I tried setting this by creating a vertex, adding x,y,z values and applying it the the Reference Point value but it doesnt work.

Any ideas how to set this property?

Cheers

Mike @ Crowns

Logged


* March 18, 2010, 10:44:26 AM
#1
Hi Mike,

From a quick overview, I don't see a way to programmatically set the reference point. Let me dig a bit deeper and I'll get back to you.

Kevan

Logged


* April 09, 2010, 08:09:29 AM
#2
Any updates ?
This would be very useful as it would enable me to control the rotation of custom shapes.

If there is a way to set the point that an object is rotated from, then this would also be useful.
 ???

Logged


* April 15, 2010, 12:45:47 PM
#3
The code in the attached Excel spreadsheet will either set a new reference point for a graphic or reset the reference point of a graphic to its original position.

To run the tool.  Make a new Turbocad drawing with a graphic of your choice and select the graphic.
Open the spreadsheet in Excel.
Push one of the two buttons or go to the Visual Basic Editor in Excel and step through either of the subroutenes using the "F8" button

The "Set Reference Point" button will
     1)Check to make sure only one graphic has been selected, selecting more than one graphic or not selecting a graphic results in a message box being displayed followed by termination of the subroutene.
     2)Set a reference to the selected graphic
     3)Get the coordinates of the reference point of the graphic.
     4)Print the coordinates of the reference point to the immediate window.
     5)Set the coordinates of the reference point of the graphic to five times the original values.
     6)Get the coordinates of the moved reference point of the graphic.
     7)Print the coordinates of the moved reference point to the immediate window.
     8)Reselect the graphic so the new reference point is shown
     9)Redraw
    10)Cleanup set objects

The "ReSet Reference Point" button will
     1)Check to make sure only one graphic has been selected, selecting more than one graphic or not selecting a graphic results in a message box being displayed followed by termination of the subroutene.
     2)Set a reference to the selected graphic
     3)Get the coordinates of the reference point of the graphic.
     4)Print the coordinates of the reference point to the immediate window.
     5)Get the Minimum and Maximum coordinates of the bounding box of the graphic.
     6)Calculate the coordinates of the center of the bounding box
     7)Print the coordinates of the center of the bounding box to the immediate window.
     8)Set the coordinates of the reference point of the graphic to center of the bounding box.
     9)Get the coordinates of the reset reference point of the graphic.
    10)Reselect the graphic so the new reference point is shown
    11)Redraw
    12)Cleanup set objects

Enjoy.

Logged


* April 21, 2010, 09:05:34 AM
#4
Nice One  ;)

That works fine,
here the code I'm using now:

newgraphic = tcApp.ActiveDrawing.Graphics(name)
newgraphic.ReferencePoint(True).X = startx
newgraphic.ReferencePoint(True).Y = starty
newgraphic.ReferencePoint(True).Z = 0

(where 'name' is the name of the graphic, previously assigned to the Info field)
easy as that!

Cheers

Mike at Crowns

Logged