Quantcast
Channel: MicroStation Programming - Forum - Recent Threads
Viewing all 1677 articles
Browse latest View live

[V8i C++] Locating elements using MstnElementSetTool class

$
0
0

I'm creating a tool derived from MstnElementSetTool. I'm trying to utilize OnPOstLocate() and OnDataButton() to allow only certain conditions that lines can be selected. Specifically, I want the user to select two lines that MUST be perpendicular and then call OnElementModify(). I'm also using my own "local" ElementAgenda so I can keep track of the selections.

bool TheApp::OnPostLocate(HitPathCP path, char *cantAcceptReason)
{
 ElemHandle  eh (mdlDisplayPath_getElem ((DisplayPathP) path, 0), mdlDisplayPath_getPathRoot ((DisplayPathP) path));
 if ( eh.GetElementType() != LINE_ELM )
 {
  strcpy( cantAcceptReason, "Not a Valid Element for this Tool" );
  return false;
 }
 if ( GetElemAgendaP()->IsEmpty() )
 {
  printf("accept\n");
  return true; // accept the first point (element)
 }
 if ( !GetElemAgendaP()->IsEmpty() )
 {
  if ( currentLine isPerpendicularTo selectedLine)
   return true;
  else
  {
   strcpy( cantAcceptReason, "Lines Not Perpendicular" );
   return false;
  }
 }
};

bool TheApp::OnDataButton (MstnButtonEventCP ev)
{
 // did anything get selected
 LocateOneElement( ev, true ); // Call/Called to locate an element and add or remove the hit
         // from the tool's ElementAgenda.
 if ( GetElemAgendaP()->GetCount() ) // if we clicked on an element....
 {
  ElemModelPairSet  modelPairSet;
  modelPairSet.Add( GetElemAgendaP()->GetFirstP( )->GetElemRef(), ACTIVEMODEL );
  m_elementAgenda.Insert( modelPairSet ); // insert into OUR local ElementAgenda
 }
 if ( m_elementAgenda.GetCount() == 2 )
 {
  OnElementModify( *GetElemAgendaP()->GetFirstP() );
  OnReinitialize();
 }
 return false;
};

 

The question is how to "reject" the datapoint when OnPostLocate() return false. When I datapoint while on the "rejected" element, the OnDataPoint() is still called, and I don't know how to reject it there...THe docs mention that LocateOneElement() can "remove the hit..."

 

Bruce

 


Re: [V8i C++] Usage of ElementAgenda.SetCapacity() in tool constructor causes crash when in debug mode

$
0
0

ElementAgenda is a class.  It inherits from std::vector<T_ElemHandle>, which is a template class (see ElementAgenda.h).

We external developers use a Release build of MicroStation.  When we build with the DEBUG switch, beware extra data or changed structures that the compiler may use to provide additional debug information.  That would be fine if the host application (MicroStation) were built using the same compiler DEBUG switches, but of course it isn't.  Our code is not binary-compatible with MicroStation.  In particular, the standard library template classes are know to add such extra information.

You can attempt to mitigate the damage by defining some pre-processor macros

Here's a comment by Keith Bentley (27-Jan-2011) on this topic …

You must compile with -D_SECURE_SCL_THROWS=1 and -D_SECURE_SCL=0 defined, even for debug builds. Otherwise you get the "checked iterators" in the stl classes and their layout changes (MicroStationAPI WString uses std::string). Likewise you cannot link with the debug CRT since MicroStation isn't linked with it.

We [Bentley Systems] have removed all uses of STL in the public API for future releases to avoid this problem. But for now the above will allow you to compile for debug.

Re: VBA- Vers 08.05.02.35

$
0
0

Thanks Robert. I am using Fence.DefineFromModelPoints but for some reason I get no object found error. The error is sporadic even within the same drawing. One time it works and the next time it bombs out? I will review the help section you outlined above. Just puzzling why it works at times and then others it bombs. It almost feels like a drawing setting is changed and I can't locate what it is? I had similar problem when fence settings were set to shape instead of block (which is now fixed)? Took me a while to figure out what was going on with that one. As you can probably guess I am an extreme novice. Thanks again for you help.

Re: VBA- Vers 08.05.02.35

$
0
0

rlb1130:
I am using Fence.DefineFromModelPoints but for some reason I get no object found error

It's because, as far as I can see, you haven't assigned your fence variable.  It's an empty object, so I would not expect it to work.

Dim nView As Integer
nView = 1
Dim points() As Point3d
... get points from somewhere
Dim oFence As Fence
Set oFence = ActiveDesignFile.Fence
oFence.DefineFromModelPoints nView, points

Trapping error with TagDefinitionName

$
0
0

Hello

I try to export cell information to Access.

The code works mostly but with some cells, like in the attached file, the export stops with an "Unknown error".

Is it possible to trapp and skip these tags?

It stops on "If Not oTags(i).TagDefinitionName = "" Then"

 

        If oElement.HasAnyTags Then

            ........

            oTags = oElement.GetTags()

            On Error Resume Next
           
            If tagUt Then
                For i = LBound(oTags) To UBound(oTags)
                    If Not oTags(i).TagDefinitionName = "" Then
                        strTag = oTags(i).TagDefinitionName
                        strTag = LCase(Replace(strTag, " ", ""))
                        If objDict.Exists(strTag) = True Then
                            rs(strTag) = oTags(i).Value
                        End If
                    End If
                Next i
            End If
           
            On Error GoTo 0

        End If

 

Thanks a lot

Hans


 

Re: Trapping error with TagDefinitionName

$
0
0

hansh:
I try to export cell information to Access

Is your VBA code running in MicroStation or in Access?

hansh:
If Not oTags(i).TagDefinitionName = "" Then

I don't think that test has any value, since a TagDefinitionName cannot be empty. Have you come across instances where there is a blank TagDefinitionName?

I used FlexiTable to analyse your DGN model. The attached ZIP archive contains tags-problem.xls with the results.

Regards, Jon Summers
LA Solutions

Re: Microstation V8i SS2 - autobreak lines

$
0
0

ok saw the video so its a work flow problem and how you cell was created  first  edit your cell so it has a background fill  same colour as the cad design plane ie black colour 255 BG  ( ie autocad speak a wash out?)

now when you place your cell it will mask the lines behind it.. next make sure you cell origin is the center 

Now download  cell tool from this user site 

http://communities.bentley.com/communities/other_communities/bentley_library/m/bentley_library_utilities/174157.aspx

it will allow you to place and rotated at the cursor other wise use accudraw RE rotate to element to align the cell to the  line element....

No need to create scripts or programing needed just use existing tools and rebuild your cell..

Lorys

Re: Change Elements Elevation with in the drawn polygon and break lines (Microstation V8i Using MDL Language or C#.Net)

$
0
0

Hi DanPaul,

Small Problem with the code provided by you.

mdlMeshDscr_fromElmdscr(&MeshElmDscr,gMSElmDescr,MASTERFILE,0,0,0,3,FALSE);

Private int mdlMeshDscr_fromElmdscr
(
  MSElementDescr    **ppResultDescr,        // result mesh
  MSElementDescr    *pSourceDescr,            // input element
  DgnModelRefP        modelRef,            // destination model
  double        chordTol,            // tolerance in master units
  double        angleTol,            // tolerance in radians
  double        maxEdgeLen,            // max edge in master units
  int            maxPerFace,            // max num of edges per face
  BoolInt        preserveVisibility        // pass FALSE for polygons
)
{
    boolean            status;
    Transform        *pTran = NULL;     
    KIENTITY        *pBody = NULL;
    MSElementDescr        *remainingEdPP = NULL;
    KIENTITY_LIST        *bodyListPP = NULL;                  
    KIENTITY_LIST        *transformListPP = NULL;
    double            kernelChordTol;
    double            kernelMaxEdgeLen;
    int            i,j;

    if (ppResultDescr == NULL || pSourceDescr == NULL)
        return ERROR;

    if (modelRef == NULL)
        modelRef = MASTERFILE;

    status = ERROR;

    mdlKISolid_beginCurrTrans(modelRef);
    
    mdlCnv_UORToMaster(&kernelChordTol, chordTol,   modelRef);
    mdlCurrTrans_invScaleDoubleArray (&kernelChordTol,   &kernelChordTol, 1);

    mdlCnv_UORToMaster(&kernelChordTol, maxEdgeLen, modelRef);
    mdlCurrTrans_invScaleDoubleArray (&kernelMaxEdgeLen, &kernelChordTol, 1);

    status = mdlKISolid_elementToBodyList(&bodyListPP, NULL, &transformListPP, &remainingEdPP, pSourceDescr,modelRef, mdlElmdscr_getFilePos(pSourceDescr), KISOLID_CACHE_NOCOPY, TRUE, TRUE );

    mdlKISolid_endCurrTrans();

    if (status == SUCCESS)
    {

        EmbeddedDPoint3dArray * pts = jmdlEmbeddedDPoint3dArray_new();
        EmbeddedIntArray      * ids = jmdlEmbeddedIntArray_new();

        for(i = 0;SUCCESS == mdlKISolid_listNthEl ((void**)&pBody, bodyListPP, i) && SUCCESS == mdlKISolid_listNthEl ((void**)&pTran, transformListPP, i);i++)
        {
            DPoint3d *vertices  = NULL;          
            long *facets        = NULL;          
            long numFacets      = 0;            
            long numVertices    = 0;

            if (SUCCESS == (status = mdlKISolid_facetBody(&vertices, &numVertices, &facets, &numFacets,pBody, pTran, maxPerFace, kernelChordTol, angleTol, kernelMaxEdgeLen)))
            {

                int id_add = jmdlEmbeddedDPoint3dArray_getCount(pts);

                jmdlEmbeddedDPoint3dArray_insertDPoint3dArray(pts, vertices, 0, numVertices);

                for (j = 0; numFacets > 0; j++)
                {
                    if (facets[j] == 0)
                    {
                        jmdlEmbeddedIntArray_addInt(ids, 0);
                        numFacets--;
                    }
                    else
                    {
                        if (preserveVisibility)
                        {
                            if (facets[j] > 0)
                            {
                                jmdlEmbeddedIntArray_addInt(ids, facets[j] + id_add);
                            }
                            else if (facets[j] < 0)
                            {
                                jmdlEmbeddedIntArray_addInt(ids, facets[j] - id_add);
                            }
                        }
                        else
                        {
                            jmdlEmbeddedIntArray_addInt(ids, abs(facets[j]) + id_add);
                        }
                        if (((j + 1) % maxPerFace) == 0)
                        {
                            jmdlEmbeddedIntArray_addInt(ids, 0);
                            numFacets--;
                        }
                    }
                }
                mdlKISolid_freeFacetArray(facets);
                mdlKISolid_freeFacetArray(vertices);
            }
        }

        status = mdlMesh_newPolyfaceFromEmbeddedArrays(ppResultDescr, &pSourceDescr->el, ids, 0, pts);

        pts = jmdlEmbeddedDPoint3dArray_free(pts);
        ids = jmdlEmbeddedIntArray_free(ids);
    }

    if (bodyListPP)      mdlKISolid_listDelete(&bodyListPP);
    if (transformListPP) mdlKISolid_listDelete(&transformListPP);

    return status;
}

1) 386425.9091, 5996533.7462, 2208.1903 Polygon Start Point Coordinates.

2) -410.0282, -267.9764, 0.5141 Mesh Start Point Coordinates


Re: Trapping error with TagDefinitionName

$
0
0

Hi

The code runs in MicroStation.

Element Information for one of the (corrupt) cells looks like this:

What I can see is this cell not included in your export to excel soyou've managed toskip thesecells.

Regards

Hans

Re: VBA- Vers 08.05.02.35

$
0
0

Thanks Jon! Seems to have worked. Will keep fingers crossed as thought I had it working before..LOL..

Re: Trapping error with TagDefinitionName

$
0
0

hansh:
Element Information for one of the (corrupt) cells looks like this

I see the same.  I don't know what could have happened to those tag elements.  It's not something that we can answer in this Forum.  I suggest that you submit a Trouble Report (TR) to Bentley Systems.

hansh:
What I can see is this cell not included in your export to excel soyou've managed toskip thesecells

FlexiTable is an MDL application.  It filters each worksheet by tag set name.  Since it can't match Unknown Error with the current set name, it simply ignores it.

Re: Change Elements Elevation with in the drawn polygon and break lines (Microstation V8i Using MDL Language or C#.Net)

$
0
0

I do not understand what you mean as problem. You must have set up correct transformation. Debug that code and find out which transform is causing the issue. I can not see your runtime values.

Re: [v8i SS2 - VBA] How to Add Multiple Entry in Config File.

$
0
0

Hi RJ,

You're potentially doing the right concept, but you are using the wrong term...  Microstation has "Config File" which are "Microstation configuration files" which have specific purposes in Microstation.  If Microstation is reading this file into it's configuration variables, then this is a "Config File".

What I believe that you have is a custom text file.  This text file is being used by your vba routines to store and retrieve your vba settings.  Microstation never directly reads your text file.  I'm going to assume that this is correct.

Here are a couple ideas for you...

1) You could write a totally different routine for your Offset Value.

2) You could assume that the offset value is the next line in your text file

3) You could just look for the offset value.

Under Idea #2--If the next line is always "Offset Value = ..." Then where you have your Exit Do statement, you could add another "Line Input #1, strLine" statement to read the next line of the text file.  Then split your string like you've already done in your code and convert the text value to a double... dblOffsetValue = CDbl(strList(3)).  The last step is to get this value back to your routine.  In your Function statement you could add.. Public Function strGetLevel(Optional dblOffsetValue as Double) As String.  Now when you call the routine, if you use a line like " abc = strGetLevel(def)" abc is the string and def is the double.

Under Idea #3-- After your End If statement you can add "If Left(.......) = "Offset Value" THEN.  After that you can use the same concept as Idea #2.

--Robert

Re: mdl call from vba

$
0
0

Thanks very much, Jon. That did the trick. Also fixed some of my erroneous assumptions regarding the translation of a couple of mdl calls that I didn't know where wrong at the time.

Stephanie

Re: [v8i SS3 MDL] Opening task navigation dialog after MDL application is loaded

$
0
0

Hi,

Even my task toolbox visible without problem, I still see below messages window on some computers. I think IconCmds are still requested before my application is loaded but refreshed after calling close/open task toolbox.

How can I prevent these messages?

How can I view Messages window on my computer?

Regards,

Ahmet Sedat ALIS


[V8 MDL] Add shared cell definition to work file

$
0
0

Hello,

I need to build a new shared cell definition from elements (something like orphan shared cell), add it to a work file and then create many instances of it in this work file.

Is it possible?

There are many functions in MDL function reference, but no one seems to have a DgnModelRefP as the destination model.

Is it correct to create a descriptor of definition element and use mdlElmdscr_addByModelRef ?

Thanks.

Re: [V8 MDL] Add shared cell definition to work file

$
0
0

DanPaul:
Is it correct to create a descriptor of definition element and use mdlElmdscr_addByModelRef ?

Yes, that will work fine...there is nothing special that needs to be done for shared cell definitions in V8.

HTH

-B

Re: [V8i C++] Locating elements using MstnElementSetTool class

$
0
0

Bruce Reeves SRNS:
The question is how to "reject" the datapoint when OnPostLocate() return false. When I datapoint while on the "rejected" element, the OnDataPoint() is still called, and I don't know how to reject it there...THe docs mention that LocateOneElement() can "remove the hit..."

Surprise, it's me!

LocateOneElement won't remove agenda entries when you pass true for newSearch, it will only add entries. LocateOneElement gets called with false from OnResetButton in order to support cycling through overlapping elements. For this reason it strikes me as problematic that you are trying to maintain your own duplicate ElementAgenda...the tool agenda, "GetElemAgendaP"  is perfectly suited to hold your two lines in the order they are selected...

If your OnPostLocate rejects an element, LocateOneElement won't change the tool agenda count, that's how you could know whether the data button accepted an element or not. NOTE: LocateOneElement is calling DoLocate, if DoLocate returns a NULL HitPath, it early returns, otherwise it inserts the path into the tool's agenda. If you're not going to use the tool's agenda, you may as well just call DoLocate yourself from your data button and reset button methods...but my recommendation is to play nice with the base class.

MstnElementSetTool of course also has built-in support for multi-select. Here's an example, it can be simplified much more since you don't need to support more than 2 elements and you probably don't care about the IElementState goop. If there's something here that isn't in the published api, pretend it's psuedocode..

HTH

-B

/*=================================================================================**//**
* Example per-element info...save original locate hit path with element.
*
* @bsiclass
+===============+===============+===============+===============+===============+======*/
struct          ExampleLocateInfo : RefCounted <IElementState>
{
private:
    HitPathCP       m_hitPath;

public:
    ExampleLocateInfo::ExampleLocateInfo () {m_hitPath = NULL;}
    ExampleLocateInfo::~ExampleLocateInfo () {mdlDisplayPath_release ((DisplayPathP) m_hitPath);}

    void            SetHitPathCP (HitPathCP hitPath) {mdlDisplayPath_release ((DisplayPathP) m_hitPath); m_hitPath = hitPath; mdlDisplayPath_addRef ((DisplayPathP) m_hitPath);}
    HitPathCP       GetHitPathCP () {return m_hitPath;}

}; // ExampleLocateInfo

/*=================================================================================**//**
* Contrived example tool:
*
* Allow user to locate multiple elements and create a linestring connecting the
* locate points. Tool completes when a minimum of 2 elements
* are selected, the control key is used to locate additional elements.
*
* Demonstrates using WantAdditionalLocate and extending BuildLocateAgenda to
* preserve the locate information using IElementSet. Using modifier transition
* event to enable/disable locate for additional input.
*
* @bsiclass
+===============+===============+===============+===============+===============+======*/
struct          ExampleTool : MstnElementSetTool
{
private:
    EditElemHandle  m_result;

public:

/*---------------------------------------------------------------------------------**//**
* ExampleTool methods
+---------------+---------------+---------------+---------------+---------------+------*/
/*---------------------------------------------------------------------------------**//**
* @bsimethod
+---------------+---------------+---------------+---------------+---------------+------*/
bool            ExampleTool::DoComputeResult (MstnButtonEventCP ev)
    {
    m_result.Invalidate ();

    EmbeddedDPoint3dArray*  pointsP = jmdlEmbeddedDPoint3dArray_grab ();

    EditElemHandleP curr = GetElemAgendaP ()->GetFirstP ();
    EditElemHandleP end = curr + GetElemAgendaP ()->GetCount ();

    for (; curr < end ; curr++)
        {
        ExampleLocateInfo*  info = dynamic_cast <ExampleLocateInfo*> (curr->GetIElementState ());

        if (NULL == info)
            continue;

        jmdlEmbeddedDPoint3dArray_addDPoint3d (pointsP, mdlHitPath_getHitPoint (info->GetHitPathCP ()));
        }

    MSElement       elm;
    MSElementDescrP edP;

    mdlLineString_create (&elm, NULL, jmdlEmbeddedDPoint3dArray_getPtr (pointsP, 0), jmdlEmbeddedDPoint3dArray_getCount (pointsP));
    mdlElmdscr_new (&edP, NULL, &elm);
    m_result.SetElemDescr (edP, true, false);

    jmdlEmbeddedDPoint3dArray_drop (pointsP);

    return m_result.IsValid ();
    }

/*---------------------------------------------------------------------------------**//**
* @bsimethod
+---------------+---------------+---------------+---------------+---------------+------*/
void            ExampleTool::SetupForLocate (int count)
    {
    __super::SetLocateCursor (count < 2 ? true : false, -1);

    UInt32      msgId = PROMPT_ExampleToolComplete;

    switch (count)
        {
        case 0:
            msgId = PROMPT_ExampleToolFirst;
            break;

        case 1:
            msgId = PROMPT_ExampleToolNext;
            break;
        }

    mdlOutput_rscPrintf (MSG_PROMPT, NULL, STRINGLISTID_Prompts, msgId);
    }

/*---------------------------------------------------------------------------------**//**
* MstnElementSet methods
+---------------+---------------+---------------+---------------+---------------+------*/
/*---------------------------------------------------------------------------------**//**
* @bsimethod
+---------------+---------------+---------------+---------------+---------------+------*/
virtual UsesSelection   ExampleTool::AllowSelection () override
    {
    // In this example don't support selection sets...(or fences MstnElementSetTool default)
    return USES_SS_None;
    }

/*---------------------------------------------------------------------------------**//**
* @bsimethod
+---------------+---------------+---------------+---------------+---------------+------*/
virtual bool    ExampleTool::DoGroups () override
    {
    // For this example don't include graphic/named group members for located element...
    return false;
    }

/*---------------------------------------------------------------------------------**//**
* @bsimethod
+---------------+---------------+---------------+---------------+---------------+------*/
virtual bool    ExampleTool::WantDynamics () override
    {
    // A preview for this type of tool would use a decorator or transients, typically not dynamics...
    return false;
    }

/*---------------------------------------------------------------------------------**//**
* @bsimethod
+---------------+---------------+---------------+---------------+---------------+------*/
virtual bool    ExampleTool::NeedAcceptPoint () override
    {
    // Accept point is required for multi-locate to give the user a chance to identity additional elements...
    return true;
    }

/*---------------------------------------------------------------------------------**//**
* @bsimethod
+---------------+---------------+---------------+---------------+---------------+------*/
virtual bool    ExampleTool::OnModifyComplete (MstnButtonEventCP ev) override
    {
    // Agenda successfully processed...write the multi-element result...
    if (m_result.IsValid ())
        m_result.AddToModel (ACTIVEMODEL);

    return __super::OnModifyComplete (ev);
    }

/*---------------------------------------------------------------------------------**//**
* @bsimethod
+---------------+---------------+---------------+---------------+---------------+------*/
virtual StatusInt   ExampleTool::OnElementModify (EditElemHandleR elHandle) override
    {
    // Located elements may be trimmed/extended etc. Return ERROR to leave unchanged...
    return ERROR;
    }

/*---------------------------------------------------------------------------------**//**
* @bsimethod
+---------------+---------------+---------------+---------------+---------------+------*/
virtual bool    ExampleTool::SetupForModify (MstnButtonEventCP ev, bool isDynamics) override
    {
    // Called before each dynamics frame and once for final accept.
    if (GetElemAgendaP ()->GetCount () < 2)
        return false; // false if not enough input to process elements...

    return DoComputeResult (ev);
    }

/*---------------------------------------------------------------------------------**//**
* @bsimethod
+---------------+---------------+---------------+---------------+---------------+------*/
virtual EditElemHandleP ExampleTool::BuildLocateAgenda (HitPathCP path, MstnButtonEventCP ev) override
    {
    // Here we have both the new agenda entry and the current hit path...save it for later!
    EditElemHandleP elHandle = __super::BuildLocateAgenda (path, ev);

    if (elHandle)
        {
        ExampleLocateInfo*  locateInfo = new ExampleLocateInfo;

        locateInfo->SetHitPathCP (path);
        elHandle->SetIElementState (locateInfo);
        }

    return elHandle;
    }

/*---------------------------------------------------------------------------------**//**
* @bsimethod
+---------------+---------------+---------------+---------------+---------------+------*/
virtual bool    ExampleTool::WantAdditionalLocate (MstnButtonEventCP ev) override
    {
    if (NULL == ev)
        return true; // This is a multi-locate tool...

    // Require a minumum of 2 elements, if control is down select additional elements...
    return (GetElemAgendaP ()->GetCount () < 2 || ev->IsControlKey ());
    }

/*---------------------------------------------------------------------------------**//**
* @bsimethod
+---------------+---------------+---------------+---------------+---------------+------*/
virtual bool    ExampleTool::OnModifierKeyTransition (bool wentDown, int key) override
    {
    // Control key state change, may need to enable/disable auto-locate, change cursor, prompts. etc.
    if (TOGGLESELECT_MODKEY != key)
        return false;

    if (GetElemAgendaP ()->GetCount () < 2)
        return false;

    SetupForLocate (wentDown ? 1 : 2);

    return true;
    }

/*---------------------------------------------------------------------------------**//**
* @bsimethod
+---------------+---------------+---------------+---------------+---------------+------*/
virtual void    ExampleTool::SetupAndPromptForNextAction () override
    {
    // All changes to auto-locate/accusnap state and user prompts are done here!!!
    SetupForLocate (GetElemAgendaP ()->GetCount ());
    }

/*---------------------------------------------------------------------------------**//**
* @bsimethod
+---------------+---------------+---------------+---------------+---------------+------*/
virtual void    ExampleTool::OnRestartCommand () override
    {
    // Must restart or call ExitTool!
    ExampleTool* newTool = new ExampleTool ();

    newTool->InstallTool ();
    }

/*---------------------------------------------------------------------------------**//**
* @bsimethod
+---------------+---------------+---------------+---------------+---------------+------*/
virtual bool    ExampleTool::OnInstall () override
    {
    if (!__super::OnInstall ())
        return false;

    SetCmdNumber (CMD_EXAMPLE_TOOL);      // For toolsettings/undo string...
    SetCmdName (CMDNAME_ExampleTool, 0);  // For command prompt...

    return true;
    }

}; // ExampleTool

/*---------------------------------------------------------------------------------**//**
* @bsimethod
+---------------+---------------+---------------+---------------+---------------+------*/
Private void    exampleToolCommand
(
char*           string,
Inputq_element* iqel
)
    {
    ExampleTool* tool = new ExampleTool ();

    tool->InstallTool ();
    }

Re: RasterManager.Rasters.Attach issue

$
0
0

It’s not the same file. The files I have to attach, are orto photographs (*.ecw), “little” big, around 24MB each one, and on one DGN, depending on its scale, from 4 or 5 to near 10 or even more. The files are in a network unit, I have tried using local files, but the problem isn’t solved.

I have tried this morning, this secuence:

1. Run Microstation and load one DGN file

2. Execute my macro, all OK

3. Open the next DGN I have to process

4. Activate View 1

5. Go to rasters manager and try to attach one file, and after selecting one, Microstation freezes, I can’t attach any file

6. After restart Microstation, I can run perfectly my macro, again.

This is the code:

Public Function vincular_ortos (dl_canton As String, ByRef refCajetin As ModelReference)

   Dim cad As String

   Dim rst As New adodb.Recordset

   Dim lineaActual As String

   Dim caracter As String

   Dim numeroFichero As Integer

   Dim rasterAuxiliar As Raster

   Dim rutaTxt As String

   Dim extension As String

   Dim distanciaPuntos As Double

   Dim vista As View

   Dim punto_medio As Point3d

   Dim cadena As String

   Dim puntos(4) As Point3d

   Dim shape As ShapeElement

   Dim shapeCajetin As ShapeElement

   Set shapeCajetin = refCajetin.GetElementByID(DLongFromString(ID_INT_CAJETIN))

   Dim rangoCajetin As New rango

   rangoCajetin.create shapeCajetin.Range.high, shapeCajetin.Range.low

   Dim oRange As Range3d

   oRange = rangoCajetin.getRango

   puntos(0).X = oRange.low.X - SUPLEMENTO_RANGO

   puntos(0).Y = oRange.low.Y - SUPLEMENTO_RANGO

   puntos(1).X = oRange.high.X + SUPLEMENTO_RANGO

   puntos(1).Y = oRange.low.Y - SUPLEMENTO_RANGO

   puntos(2).X = oRange.high.X + SUPLEMENTO_RANGO

   puntos(2).Y = oRange.high.Y + SUPLEMENTO_RANGO

   puntos(3).X = oRange.low.X - SUPLEMENTO_RANGO

   puntos(3).Y = oRange.high.Y + SUPLEMENTO_RANGO

   puntos(4).X = oRange.low.X - SUPLEMENTO_RANGO

   puntos(4).Y = oRange.low.Y - SUPLEMENTO_RANGO

   Set shape = CreateShapeElement1(Nothing, puntos, msdFillModeNotFilled)

   rutaTxt = "J:\ORTOS\" & dl_canton & "\" & "noborrar.txt"

   extension = ".ecw"

   Open rutaTxt For Input As #3

       While Not EOF(3)

           Line Input #3, lineaActual

           obtener_datos_linea lineaActual //Here I read data from one file

           Dim puntosOrto(3) As Point3d

           puntosOrto(0).X = puntoLineaBajo.X

           puntosOrto(0).Y = puntoLineaBajo.Y

           puntosOrto(1).X = puntoLineaAlto.X

           puntosOrto(1).Y = puntoLineaBajo.Y

           puntosOrto(2).X = puntoLineaAlto.X

           puntosOrto(2).Y = puntoLineaAlto.Y

           puntosOrto(3).X = puntoLineaBajo.X

           puntosOrto(3).Y = puntoLineaAlto.Y

// If one of the points readen from the file are in the range I must attach the file  

           If Point3dInPolygonXY(puntosOrto(0), shape.GetVertices) > 0 Or Point3dInPolygonXY(puntosOrto(1), shape.GetVertices) > 0 _

           Or Point3dInPolygonXY(puntosOrto(2), shape.GetVertices) > 0 Or Point3dInPolygonXY(puntosOrto(3), shape.GetVertices) > 0 Then

               ruta1 = "J:\ORTOS\" & dl_canton

               rutadef = ruta1 & "\" & nombreCot & extension

               Set rasterAuxiliar = RasterManager.Rasters.Find(rutadef)

               If rasterAuxiliar Is Nothing Then

                   RasterManager.Rasters.Attach rutadef // At this line is the error

               End If

           End If

       Wend

   Close #3

   Set vista = Application.ActiveDesignFile.Views.Item(1)

   vista.Redraw

End Function

[V8i-VBA] Enable/Disable AutoCAD units and work mode dialogs

$
0
0

I have developed a Microstation VBA application to open, extract AutoCAD tags information and create PDF/TIFF images from AutoCAD files in a specified folder.

 

I can enable/suppress the DWG/DXF Units message using the

 DWGOPEN DIALOG OPEN

 dialog.

I cannot determine how to suppress and then enable the DWG work mode dialog box. (shown below)

  

Ideally I would like to be able to programmatically suppress the two dialogs, extract tagset data and create the TIFF or PDF image, and then enable the warnings for future users.

 If this cannot be done programmatically, are there workspace variables to perform the same function?

 

Viewing all 1677 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>