昵称:烦夫子
类别:界面/平面设计师
年龄:38
现所在地:北京
主页浏览总数:24259
总积分:89
文章数:88
作品数:70
// BEGIN myline command
//
class CCommandmyline : public CRhinoCommand
{
public:
CCommandmyline() {}
~CCommandmyline() {}
UUID CommandUUID()
{
// {86D16F65-8E05-4316-B678-E4BD8F56DC41}
static const GUID mylineCommand_UUID =
{ 0x86D16F65, 0x8E05, 0x4316, { 0xB6, 0x78, 0xE4, 0xBD, 0x8F, 0x56, 0xDC, 0x41 } };
return mylineCommand_UUID;
}
const wchar_t* EnglishCommandName() { return L"myline"; }
const wchar_t* LocalCommandName() { return L"myline"; }
CRhinoCommand::result RunCommand( const CRhinoCommandContext& );
};
static class CCommandmyline themylineCommand;
CRhinoCommand::result CCommandmyline::RunCommand( const CRhinoCommandContext& context )
{
CRhinoDoc *doc = RhinoApp().ActiveDoc();
for(;;) {
CRhinoGetPoint gp;
ON_Color bkColor = RGB(255,0,0);
gp.SetCommandPrompt(prompt_msg_0003); //start line
if ( gp.GetPoint() != CRhinoGet::point )
break;
ON_3dPoint start = gp.Point();
gp.SetCommandPrompt(prompt_msg_0004); //end line
//设置动态画图形时的颜色
gp.SetDynamicDrawColor ( bkColor );
gp.DrawLineFromPoint( start, TRUE );
if ( gp.GetPoint() != CRhinoGet::point )
break;
ON_3dPoint end = gp.Point();
ON_Line mylin;
mylin.Create(start,end);
if (!mylin.IsValid())
break;
ON_LineCurve line( mylin );
CRhinoCurveObject* curveline = new CRhinoCurveObject();
curveline->SetCurve(line);
doc->AddObject( curveline, false, false );
break;
}
context.m_doc.Redraw();
return CRhinoCommand::success;
}
//
// END myline command