[quote user="Kari Heinola"]The problem is not about finding named view, but writing the saved view to hidden line file[/quote]
What about NamedView.CopyAndConvertToFile(DgnFileR destination)?
[quote user="Kari Heinola"]The problem is not about finding named view, but writing the saved view to hidden line file[/quote]
What about NamedView.CopyAndConvertToFile(DgnFileR destination)?
I need guidance on writing a tool that performs fence processing using DgnElementSetTool. Unfortunately there is no example delivered with the SDK that illustrates fence processing using DgnElementSetTool (there are some examples that perform fence processing the MDL way).
I'm attempting to write a tool that inherits from DgnElementSetTool . Its purpose is to add instance data from my Item Types schema to an existing element. After adding instance data, it creates a label that shows those data...
The tool works fine when picking (i.e. user chooses a single element). My problem lies with multiple element processing when the element source is a fence or selection set.
When a fence or select set is active, the DgnElementSetTool does its job and prompts for a data point to process the elements. It arrives at _OnElementModify() and modifies each element (adds an Item instance and creates the label). However, it doesn't stop! I'm expecting _OnModifyComplete() to be called, but I don't understand the precursors to that happening. A consequence of the interminable processing is that the tool adds dozens of labels to each element as I move the mouse, until I explicitly stop the tool with a Reset.
Specifically:
The default implementation of several DgnElementSetTool methods calls OutputErrorMessage with these enum values to output errors, for example:
bool DgnElementSetTool::_OnInstall () { if (SOURCE_Fence == _GetElemSource () && !FenceManager::GetManager().IsFenceActive ()) { OutputErrorMessage (ERROR_NUM_NoFence); return false; } if (SOURCE_SelectionSet == _GetElemSource () && !SelectionSetManager::GetManager().IsActive ()) { OutputErrorMessage (ERROR_NUM_NoSSElems); return false; } // Don't allow install if destination model is unspecified... return (INVALID_MODELREF != _GetDestinationModelRef ()); }
A sub-class of DgnElementSetTool might also want to call OutputErrorMessage to output the default error message from a method it overrides. There is no significance to the actual enum values *anymore*.
HTH
-B
Class DgnElementSetTool defines enum ErrorNums...
enum ErrorNums { ERROR_NUM_NoFence = 68, ERROR_NUM_NoFenceElems = 122, ERROR_NUM_NoFenceElemsOutside = 250, ERROR_NUM_NoSSElems = 85, ERROR_NUM_NotSuportedElmType = 609, };
Those values don't appear accidental. However, I can't see anywhere where that enum is used.
Jon,
Maybe you should post your code? One of the main reasons DgnElementSetTool was created was to make it so that tools could be mostly agnostic about where the elements originated, be it single locate, graphic group. named group, fence, or selection set.
It sounds like you are possibly writing to the DgnModel inside your _OnElementModify (instead of just updating the EditElementHandle)...and also have element dynamics enabled?
To support fences, you should return USES_FENCE_Required or USES_FENCE_Check from _AllowFence. In _OnElementModify, you should just update the EditElementHandle that is passed to you. _OnElementModify is called for both dynamics and for the final accept, DgnElementSetTool will take care of displaying the modified element or updating the file for you.
NOTE: If your tool requires dynamics and you also need to distinguish between dynamics and the final accept, you can override _OnRedrawOperation so that it doesn't just call _OnElementModify.
/*---------------------------------------------------------------------------------**//** * Called during complex dynamics. Default implementation calls _OnElementModify and * assumes it's not valid to display the modified element using an existing cache * representation. * @param el IN Current element. * @param context IN context for the redraw operation. * @param canUseCached OUT whether cached representation is still valid for display. * @return SUCCESS to not skip the display of the current element. * @see IRedrawOperation * @bsimethod +---------------+---------------+---------------+---------------+---------------+------*/ DGNVIEW_EXPORT virtual StatusInt _OnRedrawOperation (EditElementHandleR el, ViewContextR context, bool* canUseCached) override;
If you don't want dynamics return false from _WantDynamics. You might also want to then override _NeedAcceptPoint if you require an explicit data button to accept the fence, since by default it's not required to accept a fence or selection set when the tool isn't starting dynamics.
/*---------------------------------------------------------------------------------**//** * Called after populating tool's ElementAgenda to see if an explict data point * is required before accepting and calling _ProcessAgenda. By default an accept point * is required for tools that return true for WantDynamics, or for SOURCE_PICK when * the user has Auto-Locate disabled. * @return true to delay calling _ProcessAgenda until the next data point. * @bsimethod +---------------+---------------+---------------+---------------+---------------+------*/ DGNVIEW_EXPORT virtual bool _NeedAcceptPoint ();
When the tool operation is complete/accepted, then _OnModifyComplete will be called after _ProcessAgenda. Below is the documention from DgnElementSetTool.h detailing what methods are called when accepting the selected elements:
The following sequence of member function calls will occur in the case where the tool requires a single datapoint to identify the target element and to accept the modification (#_NeedAcceptPoint -> false, #_WantDynamics -> false):<ul><li>#_OnPostInstall</li><ul><li>#_SetupAndPromptForNextAction -- empty agenda</li></ul><li>#_OnDataButton</li><ul><li>#_LocateOneElement</li><ul><li>#_DoLocate</li><li>#_BuildLocateAgenda</li><li>#_ModifyAgendaEntries</li><ul><li>#_FilterAgendaEntries</li><li>#_SetupAndPromptForNextAction -- non-empty agenda</li><li>#_HiliteAgendaEntries</li></ul><li>AnchorPoint = datapoint</li></ul><li>#_ProcessAgenda</li><ul><li>#_SetupForModify -- dynamics=false</li><li>#_OnElementModify</li><li>element is written to cache</li></ul><li>#_OnModifyComplete</li><ul><li>#_OnReinitialize</li></ul></ul></ul>
NOTE: The correct way to restart your tool is to provide an implementation of _OnRestartTool that installs a new instance of your tool (see ExampleModifyTool.cpp)
/*---------------------------------------------------------------------------------**//** * Install a new instance of the tool. Will be called in response to external events * such as undo or by the base class from _OnReinitialize when the tool needs to be * reset to it's initial state. * * @bsimethod Bentley Systems +---------------+---------------+---------------+---------------+---------------+------*/ virtual void _OnRestartTool () override { InstallNewInstance (GetToolId ()); } public: /*---------------------------------------------------------------------------------**//** * Method to create and install a new instance of the tool. If InstallTool returns ERROR, * the new tool instance will be freed/invalid. Never call delete on RefCounted classes. * * @bsimethod Bentley Systems +---------------+---------------+---------------+---------------+---------------+------*/ static void InstallNewInstance (int toolId) { ExampleModifyElementTool* tool = new ExampleModifyElementTool (toolId); tool->InstallTool (); } /*---------------------------------------------------------------------------------**//** * Function that was associated with the command number for starting the tool. * * @param[in] unparsed Additional input supplied after command string. * @bsimethod Bentley Systems +---------------+---------------+---------------+---------------+---------------+------*/ Public void startExampleModifyElementTool (WCharCP unparsed) { // NOTE: Call the method to create/install the tool, RefCounted classes don't have public constructors... ExampleModifyElementTool::InstallNewInstance (CMDNAME_ExampleModifyTool); }
Hello,
i'm using Microstation V8.i ss4 C++ sdk.
Is there a way to get dynamically Point Cloud presentation style list ?
In this example, i will get the following list :
Couleur RVB, Intensité, Elévation, Classification, Elévation et intensité, Classification et intensité, PresentationA, PresentationB
Best regards
Cyrille
Using the drawing tool example from the SDK there is a method for the _onDataButton. Is there anyway to determine if this is a button up or button down event? Right now it seems to fire twice if you move the mouse while holding down the button and then release it.
I have tried using code below but the resulting file has no saved views.
DgnFileP destination = hln_file->GetDgnFileP(); NamedViewPtr nm = namedView->CopyAndConvertToFile(*destination);
For the current issue of copying saved view to work file, a simplified V8i code to convert to CE is like below.
DgnModelRefP hln_file; MSElementDescr* eldP; UInt32 filePos; mdlWorkDgn_createFile(&hln_file, filename, DGNFILE_FORMAT_V8, ACTIVEMODEL, SEED_CopyDefaultData, NULL, NULL,TRUE); mdlView_findNamedElmdscr(&eldP, &filePos, viewName, NULL, ACTIVEMODEL); mdlElmdscr_read(&eldP, filePos, ACTIVEMODEL, FALSE, NULL); mdlWorkDgn_write(eldP, -1, hln_file); mdlElmdscr_freeAll(&eldP); mdlWorkDgn_saveChanges(hln_file); mdlWorkDgn_closeFile(hln_file);
Hi,
I am migrating from v8i to Connect and wondering about mdlKISolid functions like
mdlKISolid_beginCurrTrans
mdlKISolid_elementToBody
mdlKISolid_endCurrTrans
What reference do I need or are these functions being replaced?
thanks
Nenad
I'm trying to report on the status of missing/found raster references in a dgn file. It appears I the RasterManager.Rasters only returns raster information on file open graphically, if I open a file using OpenFileForProgram the Rasters collection is empty. Can anyone verify if this is true or if I can see the raster info when opening a file non-graphically?
Hi Julien,
[quote user="Julien BIssonnette Lapierre"]via the following command[/quote]
I recommend to use Syntaxhlighlighter tool (yellow pencil icon) to insert a code to your post. This tool, when the language is set correctly, ensures it will be displayed and colorize nicely, which makes you post much easier to read.
[quote user="Julien BIssonnette Lapierre"]But I'm still trying to find how to launch a specific PowerDraft macro[/quote]
The problem is that PowerDraft 7 is really old piece of software (I guess about 19 years), so it's not compatible with technologies used today (like COM Automation API in VBA etc.) and tricks and workarounds are long forgotten.
Today, as an alternative to mentioned VBA COM access, it's possible to use e.g. -S<startup_file> parameter, but I am not sure if similar functionality was supported in version 7.
Another way can be to use configuration variable(s) to define what macro should be started when a design file is opened. For more information how to do that, see this AskInga article.
With regards,
Jan
Hello,
I'm using MicroStation PowerDraft Version 07.01.01.16 Windows x86 and I'm wondering if there's a way to open a PowerDraft .DGN file and launch a macro via an Excel VBA macro.
In other words, I want to use an Excel workbook to open a .DGN and execute a macro inside that .DGN and than close the .DGN to continue some actions in the Excel workbook.
Thank you,