Dimesion Show Change


#1

How to reduce remaining dimension on each side of object by 1Cm insted of 20cm in floorplanner app.


#2

Change how the WallReshapingTool works:

WallReshapingTool.prototype.snapPointToGrid = function (point) {
    var diagram = this.diagram;
    var newx = 1 * Math.round(point.x / 1);
    var newy = 1 * Math.round(point.y / 1);
    var newPt = new go.Point(newx, newy);
    return newPt;
}

#3

I tried with above code nothing changed.
When i am moving an object dimension are incremented / decremented by 20cm only


#4

If you want walls to not snap according to the grid size (whose default size is 20cm), the easiest way to stop this is by turning off Grid Snap. Just uncheck the box in the Options menu.

Alternatively, you could edit the functionality of snapWalls, the dragComputation for Walls, defined in FloorPlanner-Templates-Walls.js


#5

Hi Ryanj ,

I tried turning off gird snap still not able to move the object by 1cm.
And as well as in FloorPlanner-Templates-Walls.js the dragComputation function is called only when wall is move, here i am moving an object not the wall.


#6

Perhaps I’m misunderstanding what you’re trying to do. If you just want to be able to move / resize an object by 1cm, you will need to

  1. turn off Grid Snap
  2. set the Units/1px value to 1 (and ensure the selected units are “cm”). This will make it so 1px (at 100% Diagram scale) equates with 1cm

If you’re trying to do something else, please give me a reproducible example, and include what is happening now that you do not want, and what you want to happen instead.


#7

Hi Ryanj,

Thanks for the reply.
The above you have mentioned is what was required.
But when i want to move an object by 0.25Cm at that time the increments are occuring 0.25(1st increment) ,0.25(2nd increment) and 0.26(3rd increment).
Can you please help me out how can i fix this.

Floorplan.prototype.convertPixelsToUnits = function (num) {
var units = this.model.modelData.units;
return parseFloat((num * 0.14).toFixed(3));
}

also i have change the grid size

this.model = $(go.GraphLinksModel, {
modelData: {
“units”: “inches”,
“unitsAbbreviation”: “in”,
“gridSize”:1,
“wallThickness”: 5,
“preferences”: {
showWallGuidelines: false,
showWallLengths: true,
showWallAngles: true,
showOnlySmallWallAngles: true,
showGrid: true,
gridSnap: true
}
}
});

And Added interval

this.grid = $(go.Panel, “Grid”,
{ gridCellSize: new go.Size(this.model.modelData.gridSize, this.model.modelData.gridSize), visible: true },
$(go.Shape, “LineH”, { stroke: “lightgray” ,interval:120}),
$(go.Shape, “LineV”, { stroke: “lightgray”,interval:120}));


#8

I think that convertPixelsToUnits function is incorrect for your purposes. The JavaScript toFixed function rounds its argument number and then converts the number to a string: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed

I think you should change that function to return exactly the numbers that you want it to. The toFixed function should only be used when converting a number to a string. Maybe something like: function(x) { return Math.round(x*0.14*4)/4; }


#9

Hi walter ,

The problem here is increments are not uniform. i need every increment to be 0.25.
But what is happening here is that after two occurrence it increments by 0.26 instead of 0.25
for e.g increments should be like 1.25,1.50,1.75 but what actually happening is 1.25,1.50,1.76 (it should be 1.75 NOT 1.76) .
please advice

Thanks In advance


#10

I thought I gave a solution just a few minutes ago. Did you not mark it as a “Solution”? Or is there some other problem?


#11

Thanks walter that did helped.


#12

Hi walter ,
i am facing problem i did above change and now when i draw a line it is incremented by 1.5(on 1st ,2nd ,3rd,4th occurrence) and increment by 1.25(on 5th occurrence).
I need when i am creating a line it should also by incremented/decremented by 0.25 only.


#13

Could you show us a table of the input numbers and output strings that you are getting?


#14

Here is the table of input and output and their difference

input output increment Difference
6.25 7.5 1.5
7.5 9 1.5
9 10.5 1.5
10.5 11.75 1.25
11.75 13.25 1.5
13.25 14.5 1.25
14.5 16 1.5
16 17.5 1.5
17.5 18.75 1.25
18.75 20.25 1.5
20.25 21.5 1.25
21.5 23 1.5
23 24.5 1.5
24.5 25.75 1.25
25.75 27.25 1.5
27.25 28.5 1.25
28.5 30 1.5
30 31.5 1.5
31.5 32.75 1.25
32.75 34.25 1.5
34.25 35.5 1.25
35.5 37 1.5

#15

I don’t understand the problem. All of the outputs and all of the increments are multiples of 0.25, just as you said you wanted.

Or else your function’s outputs are not correct. That’s something that only you know what you want, and it doesn’t involve diagramming – it’s just plain JavaScript and numeric computations.


#16

when i am moving an object it is working perfectly (increment by 0.25).But when i am creating a line it should also be incremented by 0.25 not by multiples of 0.25. but currently it is incrementing either by 1.25 or 1.5


#17

Where is that code that does that incrementing?


#18

in floorplanner app WallBuildingTool inherit go.Tool thats where the function is written i guess. but In FloorPlann.js

if i make following changes in below function

Floorplan.prototype.convertPixelsToUnits = function (num) {
var units = this.model.modelData.units;
return Math.round(num0.0144)/4;
}

// Take a number of units, convert to cm, then divide by 2, (1px = 2cm, change this if you want to use a different paradigm)
Floorplan.prototype.convertUnitsToPixels = function (num) {
var units = this.model.modelData.units;
return Math.round((num/0.014)*4)/4;
}

it does the changes but the width of line is too big and it also reflect in other things


#19

I’m having trouble understanding your problem. If I make the changes you suggest, walls are created in .25 increments – is this not what you want?

Please give me exact, specific steps I can take to reproduce your situation, and be very clear about what is happening you do not like and what you would like to happen instead.