Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - ONCommand

#1
Hello!

Don't forget to switch the display, the Treeview and the Command echo Off during macro operation!

Depending on how many Comp-points you have this will increase the speed dramatically:



#### switch display off####
COMMAND ECHO("Off")
WINDOW REFRESH ("Off")
TREEVIEW REFRESH ("Off")

...
..
.
#### switch display on####
TREEVIEW REFRESH ("On")
WINDOW REFRESH ("On")
COMMAND ECHO("On")

TREEVIEW REFRESH NOW
WINDOW REFRESH NOW
### Macro end ###



regards, Oliver
#2
Inspector / Re: Vector tangent to a circle
March 11, 2010, 12:20:01 PM
Hello Jeff!

I thought a bit about your question and realized a small macro, which does what you ask for in your first post.
(at last two tangents will be created)
Since every tangent to a circle is always orthogonal to its axis, this would only work with nominals, where one axis orientation is exactly 0 ...

I do not test any circle orientation , so there might be some bugs ...


# Create Tangent to Circle
# Macro creates two tangents to a circle parallel to a specified axis
# (c)2010 O.Niessen
# http://www.ONCommand.de

### Todo:  test for all possible circle orientation 10/03/11###
version "4.0"


# ----- Declare some error messages -----
Declare ErrorMsgTitle "Circle-tangent error"
Declare ErrorMsgNumber "More than one or no complete feature selected!!"
Declare ErrorMsgCircle "No circle selected!!"
Declare ErrorMsgOrto "Circle is not orthogonal to axis!!"
# ----- Declare Message Text -----
Declare AxisMsgTitle "Parallel axis?"
Declare AxisMsgText "Specify the desired parallel axis"

# -----  some error Handling -----
DECLARE NB_selected 0
TREEVIEW FEATURE GET_NB_SELECTED(NB_selected)
IF $NB_selected != 1
    MACRO PAUSE($ErrorMsgTitle, $ErrorMsgNumber)
    MACRO END
ENDIF
SET NB_selected 0
TREEVIEW FEATURE CIRCLE GET_NB_SELECTED(NB_selected)
IF $NB_selected != 1
    MACRO PAUSE($ErrorMsgTitle, $ErrorMsgCircle)
    MACRO END
ENDIF
# -----------------------------------------


# --- Get ID of selected circle ----
DECLARE breakpoint
DECLARE select "Off"
DECLARE i 0
TREEVIEW FEATURE CIRCLE GET_NB (breakpoint)
While $select != "On"
    ++i
    if $i > $breakpoint
        break
    endif
    TREEVIEW FEATURE CIRCLE GET_SELECTION_STATUS ($i, select) 
endwhile

# ---- Read out circle nominal values ----
DECLARE Center_X
DECLARE Center_Y
DECLARE Center_Z
DECLARE Axis_X
DECLARE Axis_Y
DECLARE Axis_Z
DECLARE Radius
DECLARE C_Name
TREEVIEW FEATURE CIRCLE GET_NAME ($i, C_Name)

TREEVIEW FEATURE CIRCLE NOMINAL SELECT($i)
TREEVIEW PRIMITIVE CIRCLE PROPERTIES CENTER GET(Center_X, Center_Y, Center_Z)
TREEVIEW PRIMITIVE CIRCLE PROPERTIES AXIS_ORIENTATION GET(Axis_X, Axis_Y, Axis_Z)
TREEVIEW PRIMITIVE CIRCLE PROPERTIES RADIUS GET (Radius)

# --- Input of the parallel Axis ----
DECLARE P_Axis
INPUT STRING(P_Axis, $AxisMsgTitle, $AxisMsgText, "x" )
# May be simpler, to look, which axis is/are orthogonal to circle axis
# then maximally 4 tangents may be created


# ------- Execution --------
# May create a false tangents , depending on Circle-axis-orientation/Circle-center-orientation
### Todo:  test for all possible circle orientation 10/03/11###

Declare Vector_X
Declare Vector_Y
Declare Vector_Z

IF $P_Axis == "x"
        IF $Axis_X > 0
        # -----  some error Handling -----
        MACRO PAUSE($ErrorMsgTitle, $ErrorMsgOrto)
        MACRO END
        ENDIF
    #    Build the nominal vectors with length of 25
    set Vector_X $center_X
    set Vector_Y expr($center_Y - $Radius * -$Axis_Z)
    set Vector_Z expr($center_Z - $Radius * $Axis_Y)
    FEATURE PRIMITIVE VECTOR CREATE($Vector_X, $Vector_Y, $Vector_Z, 1, 0, 0, 25, "nominal","X-tangent 1 to $C_Name")
    set Vector_X $center_X
    set Vector_Y expr($center_Y - $Radius * $Axis_Z)
    set Vector_Z expr($center_Z - $Radius * -$Axis_Y)
    FEATURE PRIMITIVE VECTOR CREATE($Vector_X, $Vector_Y, $Vector_Z, 1, 0, 0, 25, "nominal","X-tangent 2 to $C_Name")
ENDIF
IF $P_Axis == "y"
    IF $Axis_Y > 0
    # -----  some error Handling -----   
    MACRO PAUSE($ErrorMsgTitle, $ErrorMsgOrto)
    MACRO END
    ENDIF       
    #    Build the nominal vectors with length of 25
    set Vector_Y $center_Y
    set Vector_X expr($center_X - $Radius * -$Axis_Z)
    set Vector_Z expr($center_Z - $Radius * $Axis_X)
    FEATURE PRIMITIVE VECTOR CREATE($Vector_X, $Vector_Y, $Vector_Z, 0, 1, 0, 25, "nominal","Y-tangent 1 to $C_Name")
    set Vector_Y $center_Y
    set Vector_X expr($center_X - $Radius * $Axis_Z)
    set Vector_Z expr($center_Z - $Radius * -$Axis_X)
    FEATURE PRIMITIVE VECTOR CREATE($Vector_X, $Vector_Y, $Vector_Z, 0, 1, 0, 25, "nominal","Y-tangent 2 to $C_Name")
ENDIF
IF $P_Axis == "z"
    IF $Axis_Z > 0
    # -----  some error Handling -----   
    MACRO PAUSE($ErrorMsgTitle, $ErrorMsgOrto)
    MACRO END
    ENDIF
    #    Build the nominal vectors with length of 25
    set Vector_Z $center_Z
    set Vector_X expr($center_X - $Radius * -$Axis_Y)
    set Vector_Y expr($center_Y - $Radius * $Axis_X)
    FEATURE PRIMITIVE VECTOR CREATE($Vector_X, $Vector_Y, $Vector_Z, 0, 0, 1, 25, "nominal",,"Z-tangent 1 to $C_Name")
    set Vector_Z $center_Z
    set Vector_X expr($center_X - $Radius * $Axis_Y)
    set Vector_Y expr($center_Y - $Radius * -$Axis_X)
    FEATURE PRIMITIVE VECTOR CREATE($Vector_X, $Vector_Y, $Vector_Z, 0, 0, 1, 25, "nominal",,"Z-tangent 2 to $C_Name")   
ENDIF


Feel free to modify it or use it as Idea... :-)

I think a macro to create any tangent from a point to a circle(if possible) or between two circles(in the same plane!!! and if possible...) could be realized in a similar way...


regards, Oliver

#3
Inspector / Re: Vector tangent to a circle
March 11, 2010, 01:31:41 AM
Since You should have all necessary information(in the feature), I think you might realize this with a macro.

But by now, I do not know exaktly what you mean?
E.g. there are mostly two tangents to a circle parallel to Y axis ...
and is it made sure, that the circle is exactly orientated in the XY-Plane or YZ Plane?

regards, Oliver



#4
Macro World / Re: Sub String question
February 05, 2010, 04:31:41 AM
Or you might use the SplitString()Command of the ONCommand Plugin...

Unfortunately only availible for the 32bit version at the moment - but I look forward...

As addition to Admin's soulution,(which works very well!!) I would recommend to build up a small Ram-Drive(1-10MB) for such cases as Volume Z: .
You find a Description on the www.ONCommand.de Website at Tips and Tricks...

Regards, Oliver

P.S. I do not find any introduction topic/thread, so I hope, I am welcome anyway:-)