70001272 Add 3d objects in scriptCommands

Article 70001272
Type Wish
Product WebJS
Version 7012
Date Added 2/15/2018
Fixed 7.7015.0.2 (4/13/2018)
Submitted by Brendan Fry

Summary

I would like to use the 3d object as in scriptCommand for polyline etc., so they will go in the undo buffers.

Solution

In version 7015.0.2 scriptCommand.box ,cone ,sphere commands with user action have been added, which are also write to the undo buffer.

vdrawobj.scriptCommand.box(object[] parameters, ScriptEntityDelegate callback)

Add a new box to the document.If passed parameters are null then start a new user action and prompts the user to draw a box.
If parameters are not null then a new box is added synchronously depend on the passed parameters.
If parameters are not null and after this command is finished the object is not drawn on screen
In order to display it call vdrawObj.DrawEntity and vdrawObj.Refresh inside the user define callback.
parameters:An array  that contains the InsertionPoint,the length,the width,the height and the rotation of the box.For example it can be [[1, 2, 3], 1, 2, 3, vdgeo.HALF_PI / 2.0] 
callback:If the command is not finished succesfully then the entity may be null.Also user must check the vdraw.ActiveAction().IsCanceled() to determine if the command is canceled by user.
Example_1: Begins a user action to draw a new box.

   vdrawobj.scriptCommand.box(null, callback); // begins a user action to draw a box

Example_2: Draw a new box using active color,linetype,layer etc properties, insertion point [1,2,3] with length 1,width 2,height 3 and rotation HALF_PI / 2.0 or 45 degrees

   vdrawobj.scriptCommand.box([[1, 2, 3], 1, 2, 3, vdgeo.HALF_PI / 2.0]);
   setTimeout(vdrawObj.redraw);//post a redraw command

Example_3: Draw a new box using active color,linetype,layer etc properties, insertion point [1,2,3] with length 1,width 2,height 3 and rotation HALF_PI / 2.0 or 45 degrees using also the callback.

   function actionentityadded(vdraw, entity) {
        vdraw.DrawEntity(entity);// in order to be drawn the new entity on the screen
        setTimeout(vdraw.Refresh);//post a refresh command in order the canvas to be refreshed and see the entity on the screen
   }
   vdrawobj.scriptCommand.box([[1, 2, 3], 1, 2, 3, vdgeo.HALF_PI / 2.0], actionentityadded);


vdrawobj.scriptCommand.cone(object[] parameters, ScriptEntityDelegate callback)

Add a new cone to the document.
If passed parameters are null then start a new user action and prompts the user to draw a cone.
If parameters are not null then a new cone is added synchronously depend on the passed parameters.
If parameters are not null and after this command is finished the object is not drawn on screen
In order to display it call  and   inside the user define callback.
parameters:An array  that contains InsertionPoint,BaseRadius,TopRadius,height and the Segments number controling how smooth the cone will be.For example it can be [[0,0,0],2,1,3,10]
callback:If the command is not finished succesfully then the entity may be null.Also user must check the vdraw.ActiveAction().IsCanceled() to determine if the command is canceled by user.
Example_1: Begins a user action to draw a new cone.
 
     vdrawobj.scriptCommand.cone(null, callback); // begins a user action to draw a box
      
Example_2: Draw a new cone using active color , linetype,layer etc properties, insertion point [1,2,3] with BaseRadius 2,TopRadius 1,height 3 and Segments number 10.
    
       vdrawobj.scriptCommand.cone([[1,2,3],2,1,3,10]);
        setTimeout(vdrawObj.redraw);//post a redraw command
     
Example_3: Draw a new cone using active color , linetype,layer etc properties, insertion point [1,2,3] with BaseRadius 2,TopRadius 1,height 3 and Segments number 10, using also the callback.
       
         function actionentityadded(vdraw, entity) {
            vdraw.DrawEntity(entity);// in order to be drawn the new entity on the screen
            setTimeout(vdraw.Refresh);//post a refresh command in order the canvas to be refreshed and see the entity on the screen
        }
        vdrawobj.scriptCommand.cone([[1,2,3],2,1,3,10], actionentityadded);



vdrawobj.scriptCommand.sphere(object[] parameters, ScriptEntityDelegate callback)

Add a new sphere to the document.
If passed parameters are null then start a new user action and prompts the user to draw a sphere.
If parameters are not null then a new sphere is added synchronously depend on the passed parameters.
In order to display it call vdrawObj.DrawEntity and vdrawObj.Refresh inside the user define callback.
parameters:An array  that contains the CenterPoint,the radius,the longitudinalsegs and the latitudinalsegs.For example it can be [[1, 2, 3], 2, 10, 5]
callback:If the command is not finished succesfully then the entity may be null.Also user must check the vdraw.ActiveAction().IsCanceled() to determine if the command is canceled by user.
Example_1: Begins a user action to draw a new sphere.
   
      vdrawobj.scriptCommand.sphere(null, callback); // begins a user action to draw a sphere
      
Example_2: Draw a sphere using active color , linetype,layer etc properties,insertion point [1,2,3] with radius 2,longitudinalsegs 10 and latitudinalsegs 5.
   
      vdrawobj.scriptCommand.sphere([[1, 2, 3], 2, 10, 5]);
       setTimeout(vdrawObj.redraw);//post a redraw command
      
Example_3: draw a sphere using active color , linetype,layer etc properties, insertion point [1,2,3] with radius 2,longitudinalsegs 10 and latitudinalsegs 5, using also the callback.
      
        function actionentityadded(vdraw, entity) {
            vdraw.DrawEntity(entity); //in order to be drawn the new entity on the screen
            setTimeout(vdraw.Refresh);//post a refresh command in order the canvas to be refreshed and see the entity on the screen
        }
        vdrawobj.scriptCommand.sphere([[1, 2, 3], 2, 10, 5], actionentityadded);

For more information check out our help file.



Send comments on this topic.