IceRevenge
IceRevenge

Reputation: 1583

ACC Viewer 2D: coloring and selecting polylines

When we load any dwg file into the ACC viewer we want to be able to easily select (click) and color (theme) the polylines/polygons that represent spaces.

If you simply load a dwg the only way to select a Polyline in the graphic is by clicking exactly on the outline of the element - clicking on the inside of a polygon does not lead to it being selected. When a polyline is selected it is very hard to notice that it is selected because only the polyline changes its color and not the filling of it.

In the picture below I selected a polyline that describes the orange colored space (its outline is slightly blue now). I want the entire polyline to be filled. enter image description here

This also means it is not possible to fill the entire polyline in one color using the setThemingColor. When I try calling that function I don't notice any visible change of the space.

We solved this problem by editing the original dwg and adding Solid (or Hatches) on top of each polyline and that works nicely. We can click these hatches easily (by also clicking somewhere inside of it and not only the line itself) and color them properly. This is an example of a selected hatched space: enter image description here

Now we need a way without editing the drawing file itself. I could think of several options but I was wondering which one is possible and the easiest to do.

  1. Is there a setting in the viewer I am missing that will allow this?
  2. Could I add those hatches manually at runtime when the drawing is loaded ontop of each original polyline in the dwg?
  3. I guess one could catch click events on the viewer and calculate inside of which element the user clicked and then select that element per api. This could work for the easier selection but wouldn’t solve the coloring problem…

Be aware that the filled polylines/hatches should be at the lowest level in the drawing so all of the other elements are not visibly blocked by it - this order should be defined in the drawing already. As a bonus we would also be interested in having a similar solution for any kind of blocks: enter image description here Clicking is more important for the blocks than the filling of it so the 3rd solution might work for them.

How would I implement the above ideas - if they are possible? Or is there a better solution?

Upvotes: 0

Views: 76

Answers (1)

michael beale
michael beale

Reputation: 1196

Sounds like you are creating your own viewer (seperate from the built in ACC/BIM Viewer), right?

Great, that's a good start.

If for some reason you absolutely need to customize the highlighting, selection and hovering behaviors, you may want to get access to the underlining shape geometry first.

Use this to do that: https://aps.autodesk.com/blog/move-entities-2d-drawing

Next, use the edit2d class to recreate the geometry you want, and begin customizing the UI controls and behavior without effecting the underlining drawing.

https://aps.autodesk.com/en/docs/viewer/v7/developers_guide/advanced_options/edit2d-manual/

Upvotes: 1

Related Questions