Archicad C++ API
About Archicad add-on development using the C++ API.

changing visible-state of a layer (before addon quits)

Anonymous
Not applicable
Hi 🙂

I try to make a layer invisible from the modal dialog of my addon.

Problem: The layer does not becomee invisible before the dialog is closed.

I think this are the relevant lines of my code:

mAcAttribute.layer.head.flags = APILay_Hidden;
GSErrCode err = ACAPI_Attribute_Modify(&mAcAttribute, NULL);
GSErrCode err = ACAPI_Database(APIDb_RedrawCurrentDatabaseID, NULL, NULL);

I hope someone has a hint for me 🙂

Does "APIDb_RedrawCurrentDatabaseID" not cover layers?

regards,

John Mueller
6 REPLIES 6
Anonymous
Not applicable
> Does "APIDb_RedrawCurrentDatabaseID" not cover layers?

I found something:
GSErrCode err = ACAPI_Automate(APIDo_RedrawID, NULL, NULL);

now the handles of the selected elements painted in light grey instead of black when setting layer to be invisible.

the elements do not become invisible befor the addon quits. 😞

Has no one ever tried to switch the visible-state of a layer during the addon is running?
Ralph Wessel
Mentor
John wrote:
Hi 🙂
I try to make a layer invisible from the modal dialog of my addon.
Problem: The layer does not becomee invisible before the dialog is closed.
John,

I don't it is possible for changes like this to be displayed while a modal dialog box is active.

It sounds to me as if you might be trying to work against ArchiCAD's UI principles. Can you roughly describe why you want to do this? There may be a better approach to the problem.

Ralph.
Ralph Wessel BArch
Software Engineer Speckle Systems
Anonymous
Not applicable
Hi Ralph :-)
Ralph wrote:
John wrote:
Hi 🙂
I try to make a layer invisible from the modal dialog of my addon.
Problem: The layer does not becomee invisible before the dialog is closed.
Can you roughly describe why you want to do this? There may be a better approach to the problem.
Sure:
The Addon processes the selected lines, arcs and polylines and closes the gaps between the elements if the distance is below a defined threshold.
A new polyline containing the elements is created.

Example:
line1 (0/0)(1.0001/0.9991)
line2 (1/1.0001)(2/0)
->
polyline (0/0)(1/1)(2/0)

The original-elements are on layer A.
The polyline is created on an layer B.

I want to to toggle between:
1. A visible / B invisible
2. A invisible / B visible

Elements the addon could not connect to a polyline because of ambiguity are to be moved to a problem-layer.
Example:
line1 (0/0)(1.0001/0.9991)
line2 (1/1.0001)(2/0)
line3 (0.0009/1.0001)(0/2)

greetings,
john
Anonymous
Not applicable
Maybe you could just use a modeless dialog. Why does it have to be modal?
Anonymous
Not applicable
adambutler wrote:
Maybe you could just use a modeless dialog. Why does it have to be modal?
Oh, do you think it would work with a modless dialog? That would be great 🙂

I tried a modeless dialog, but it closed immediately, after I created it and the addon quits.
Docu says: "DGModelessInit returns immediately as soon as the dialog is created."

Hmm, do you have a hint how to keep the addon running?

I am a rooky... Is there a way to code an idle-loop or what is the way you would handle this?

I will browse the docu again 🙂
Ralph Wessel
Mentor
John wrote:
The Addon processes the selected lines, arcs and polylines and closes the gaps between the elements if the distance is below a defined threshold.
A new polyline containing the elements is created.
...
The original-elements are on layer A.
The polyline is created on an layer B.
...
I want to to toggle between:
1. A visible / B invisible
2. A invisible / B visible
John,

The process you describe raises a lot of questions. I don't understand why you need a dialog for this at all - could it work in the following way:
  • 1) The user selects the elements they want to join
    2) The user picks a menu item from your add-on
    3) The add-on joins the elements (if possible) and creates a new polyline element.
    4) The add-on deselects the original elements and creates a selection with the new polyline.
Layer toggling is well catered for in ArchiCAD with Layer sets, Views, and the contextual menu to Hide/Show Layers. Are you sure your add-on needs to do this?

Also, the magic wand is pretty good at joining elements. Perhaps you are looking at larger tolerences than it works to?

Ralph.
Ralph Wessel BArch
Software Engineer Speckle Systems