/
Android: DWG Editor

Android: DWG Editor

The DWG Editor carries the basic features and extends the creation and editing capabilities of entities.

Features

  • Create new drawings

  • Change system variable CECOLOR

  • Offer basic drawing and editing tools

  • List and insert existing block definitions

  • Show custom help content

 

DWG Editor - Create new drawings JAVA

The DWG Editor uses the command SMARTNEW to create a new document. The command is executed with runCommand() method of CFxARESInstance.instance(). Once the drawing is loaded the CFxARESDelegate triggers documentCreated() followed by documentActivated().


Note: Templates can be opened with command NEW. A possible command expressions will work like this "_NEW\n" + fileName + "\n";

 

File: MainActivity.java

private void CreateNewDocument() {    m_ARESView.setVisibility( View.VISIBLE );    String command = "_SMARTNEW\n";    CFxARESInstance.instance().runCommand( command, false ); }



DWG Editor - Change system variable CECOLOR JAVA C++

The DWG Editor uses a native method to change the database variable CECOLOR, the current entity color when created. The offered color indexes are provided by a custom color panel. The necessary  JNI method SetCECOLOR() is called when the dedicated color button is tapped. The JNI method accesses the C++ part of the application  and must be executed within the working thread. A suitable method runOnWorkingThread() is provided by CFxARESInstance.instance() .

 

File: JNI.java

public static native void SetCECOLOR( int color );

 

File: ARES_Simplified_JNI.cpp

JNIEXPORT void JNICALL Java_com_graebert_dwgeditor_JNI_SetCECOLOR( JNIEnv * env, jclass clazz, jint color ){ ... }



File: ColorPanel.java

 

DWG Editor - Offer basic drawing and editing tools JAVA

The DWG Editor resorts to commands like LINE, CIRCLE and POINT to provide basic 2D drawing tools and commands like MOVE, SCALE and DELETE for basic editing features. The commands can be easyly executed with the runCommand() method of CFxARESInstance.instance().The Commands to choose are offered by a custom command panel. All commands require user actions to complete. User actions are controlled by the default user input interface.

 

Note: The DWG Expert explains how to overwrite the default user input and create a custom feature that fits better inside the host application.

 

File: CommandPanel.java

 

DWG Editor - List and insert existing block definitions JAVA C++

The DWG Editor uses a native method GetBlockNames() to get all available block definitions of the drawing when the delegate CFxARESDelegate triggers documentActivated(). All block definition names are passed to the method DocumentActivated() of the main activity and are stored temporarily while the drawing is opened. The DWG Editor provides a button that can list all available blocks with a simple AlertDialog. When a block is chosen , a suitable command expression using the command -INSERTBLOCK is created and executed with runCommand().

 

File: JNI.java


File: ARES_Simplified_JNI.cpp

 

File: MainActivity.java

 

DWG Editor - Show custom help content JAVA C++

The SDK is shipped without a command help but the standard user input shows a help button. To hide the help button just use SetUIConfigruation() from CFxARESInstance. More details read here → DWG Expert - Create a custom UI for command prompts

The delegate method onHelp() of CFxARESInstanceDelegate allows to react whenever the user taps on the help button of a certain command. The command name is provided in English only.

File: CFxARESDelegate.java

Related content

Android: Sample Project ARESSimplified_android
Android: Sample Project ARESSimplified_android
More like this