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

[Connect CPP] Place label programmaticaly

$
0
0

Hi

In V8i we are using tags in some of our applications. In MicroStaton Connect we would like to use items instead. When you work with tags you can choose whether they should be visible or not. In CE you can use the "Place Label" tool to show the value of the items you want using a cell. Now I would like to do that programmatically. I've looked through the documentation and I've found the method CreateLabel in the LabelCellHeaderHandler struct. When I look through the list of parameters I think that something is missing. You can specify the cell you want to use for labelling but as far as I can see there is no way to specify the element you want to extract values (itemtype values) from.

Have I missed something somewhere ?

Regards,

Evan


RE: [V8i VBA] Cell Creation and Annotation Scale

$
0
0

We can't see where that error occurs.  Step through the code using Debug to determine the line where that occurs.

Use assertions to test your assumptions.  For example...

Set oCell = CreateCellElement2(...)
Debug.Assert Not oCell Is Nothing

Your code looks similar to the example Annotation Scale for Elements in VBA help, so it should be OK.  The only thing that occurs to me is that you're modifying a brand new cell in memory that has not been written to file.  Does it make any difference if you add it to the model, apply annotation, then re-write it?

Set oCell = CreateCellElement2(cellName, pts(N), Point3dFromXYZ(1,1,1), True, matrix)
ActiveModelReference.AddElement oCell

Dim propH                                As PropertyHandler
Set propH = CreatePropertyHandler(oCell)
propH.SelectByAccessString ("UseAnnotationScale")
propH.SetValue True
oCell.Rewrite

RE: [V8i VBA] Cell Creation and Annotation Scale

$
0
0

[quote user="Jon Summers"]

Your code looks similar to the example Annotation Scale for Elements in VBA help, so it should be OK.  The only thing that occurs to me is that you're modifying a brand new cell in memory that has not been written to file.  Does it make any difference if you add it to the model, apply annotation, then re-write it?

1
2
3
4
5
6
7
8
SetoCell = CreateCellElement2(cellName, pts(N), Point3dFromXYZ(1,1,1), True, matrix)
ActiveModelReference.AddElement oCell
 
DimpropH                                AsPropertyHandler
SetpropH = CreatePropertyHandler(oCell)
propH.SelectByAccessString ("UseAnnotationScale")
propH.SetValue True
oCell.Rewrite

[/quote]

Afternoon Jon

The highlighted error line shown in the debug is propH.SetValue True. I tried your suggested code change and the debug assert line but it errors at the same position.

RE: [V8i VBA] Cell Creation and Annotation Scale

$
0
0

[quote user="Barry Lothian"]The highlighted error line shown in the debug is propH.SetValue True[/quote]

That method is documented as taking Variant, Point3d etc.  I think Boolean should be handled as a Variant, but possibly VBA objects to a constant value rather than a Variant variable.  Try this (you realise I'm grasping at straws?)...

Dim newValue As Variant
newValue = True
propH.SetValue newValue 

RE: MVBA causing Microstation to lock up?

$
0
0
I seem to be running into this issue with many of my customers recently. The only solution I have found is deleting the VBA file.. Luckily I have just about finished up phasing out all VBA.

RE: MVBA causing Microstation to lock up?

$
0
0
If it happens again I will probably get rid of it as well. I only use it for rotating text to match the rotation of an element. There are other ways to do that but nothing as quick and easy as that VBA that I know of.

MVBA causing Microstation to lock up?

$
0
0

I regularly use the ActiveAngleAssistant.mvba with V8i and it usually works fine. I recently had an issue where that MVBA caused MicroStation to lock up. It's set to pre-load in my workspaces which wouldn't allow MicroStation to get past the splash screen. It took me half a day to figure out what was going on. The MVBA has not changed and I even replaced it with files directly downloaded from here and got the same result. It was only affecting my machine and there were no program or Windows updates since the day before when it was still working. I ended up using a restore point on my computer from last week to fix the problem. Anyone have any ideas what might have changed or gone wrong? 

RE: [V8i VBA] Cell Creation and Annotation Scale

$
0
0

[quote user="Jon Summers"]

Try this (you realise I'm grasping at straws?)...

[/quote]
Heh, it's probably the first time I've found you struggling with a query :/
I tried changing the variable type but its the same error. I get the feeling its because the cell only exists in memory and not in the file (like you suggested in your first reply). Any propertyhandler examples I've seen involve enumerating and scanning a file which is possible to do after the cell creation but gives rise to the potential of applying annotation scale to other cells in the active model which would be undesirable. I do have the option of not using annotation cells and simply adding a textbox to my form and using its value to set the cell scale e.g.:
 Set oCell = CreateCellElement2(cellName, pts(N), Point3dFromXYZ(tbCellScale.Value, tbCellScale.Value, tbCellScale.Value), True, matrix)
Not necessarily elegant but it does work.
Perhaps Robert Hook or Yongan.Fu can confirm (if either see this topic) if its possible(or not) in VBA to apply the useannotationscale property during cell creation.

Setting a loaded raster to read/write in VBA (Microstation v8.5)

$
0
0

I'm trying to change the Read/Write status of an attached raster through VBA.

Recording a macro gave me the following code.

SetCExpressionValue "tRMDlgSettings.bOpenReadOnly", 1, "RASTMGR"

This worked to change it back and forth if I used a 1 or 0, but after testing a few times it no longer applies the change.

If I have the attachment settings window open, it will uncheck the box but the apply button is greyed out still. If I click okay after VBA unchecks the box, nothing happens. If I click it myself I can then click apply or ok and it works fine. Any ideas?

I tried to replicate results in Powerdraft but the attachment settings dialog doesn't seem to exist.

RE: [CONNECT DgnPlatformNet] How do I measure dimensional properties?

$
0
0

At this time the managed API does not provide direct access to element linear and volumetric properties.  We will file a enhancement request to get the functionality added.  Until that time, here are a couple work-arounds to consider as options.

  1. EC API - extract EC property values
  2. COM API - extract using available methods
  3. MDL API - extract using available (wrapped) native methods

I will update reply once the enhancement request has been filed.

[UPDATE]  Enhancement 614245 has been filed to address this request

HTH,
Bob

[CONNECT DgnPlatformNet] How do I measure dimensional properties?

$
0
0

If I'm writing a C# AddIn using the DgnPlatformNet, how do I get planar properties such as area & perimeter?  How do I obtain volumetric properties such as volume & centroid?

RE: Microstation VBA - calling mdl function - mdlSurface_extractExtrusion

$
0
0
Jon, do you have a similar solution for Type 19?
Im trying to do the same thing for solids

Regards,

Cesar

RE: Microstation VBA - calling mdl function - mdlSurface_extractExtrusion

$
0
0

[quote user="Cesar Mattos"]Do you have a similar solution for Type 19?[/quote]

Please start a new thread.  This thread is (a) stale and (b) lengthy.  Also, I'm unsure what a 'similar solution' might be.  There's little difference between a type 18 (surface) and a type 19 (solid). 

RE: Microstation VBA - calling mdl function - mdlSurface_extractExtrusion

Microstation VBA - calling mdl function - mdlSurface_extractExtrusion

$
0
0

Hi,

I have a type 18 suface element that contains two line strings (and a lot of other line element that I'm not interested in) that are being used to represent railway rails in a 3d drawing. I've been trying to extract the line string information from the surface in vba, but there doesn't appear to be much support for surfaces in the vba / com interface, so I've ended trying the get the line information out by the calling the mdl function "mdlSurface_extractExtrusion". (I arrived at this function after poking round and reading other posts on these forums of a similar nature).

The mdl function appears to be getting called correctly but I'm getting -105 (MDLERR_BADELEMENT) as the return value. The distance variable reference that is passed to the mdl function also gets updated after the function call, so I think I'm almost there. I just can't figure out what I need to do to fix it?

Is mdlSurface_extractExtrusion the correct function to call to get the line string out of a this surface?

The direction point3d that I'm passing into the function is a point above the surface. I've noticed that in the mdl reference the distance parameter in the mdl function call is a 3d vector but in the vba wrapper offered in the mdl reference, it is declared as point 3d so assume that the vector angle is truncated in the conversion to point3d. Don't know if that is important or not though?

Any help or pointing in the right direction would be greatly appreciated.

Thanks

Jim

My code looks like this:

DeclareFunctionmdlSurface_extractExtrusionLib"stdmdlbltin.dll" (ByRef edPP AsLong, ByRef directionP As Point3d, ByRef distanceP AsDouble, ByVal surfaceEdP AsLong) AsLongSubDumpSurfaceDetails()
    Dim elements As ElementEnumerator
    Set elements = ActiveModelReference.GetSelectedElements
    
    While elements.MoveNext
        If elements.Current.Type =18ThenDim elementDescPtr AsLong
            elementDescPtr = elements.Current.MdlElementDescrP(False)
            
            Dim distance AsDouble
            distance =10Dim direction As Point3d
            direction = Application.Point3dFromXYZ(150752.8186, 443929.0342, 22.9228)
            
            Dim returnedPointer AsLongDim success AsLong
            success = mdlSurface_extractExtrusion(returnedPointer, direction, distance, (elementDescPtr))
            
            If returnedPointer >0ThenDim element As element
                Set element = MdlCreateElementFromElementDescrP(returnedPointer)
            EndIfEndIfWendEndSub

RE: [V8i VBA] Cell Creation and Annotation Scale

$
0
0
Hi Barry,

a few quick notes "without hands-on coding":

In my opinion PropertyHandlers can be used with elements existing in ElementCache (in design file). Until the element is added, it exists in memory only and it's not fully initialized, e.g. it does not contain ElementId.

I see no problem to add the cell to design file and to make any necessary modifications afterwards. It's quite common approach in some situations, simply because some modifications cannot be done until the element is fully "initialized" (stored in persistent storage like design file), sometimes also because VBA API is too limited and there is no other option.

After you add the element to design file, you can use ActiveModelReference.GetLastValidGraphicalElement method to get the created cell back from the file. Have no time to test it, but I guess the handlers should work then.

With regards,

Jan

[V8i VBA] Cell Creation and Annotation Scale

$
0
0

I'm looking to update a macro which creates and places a cell using CreateCellElement2 however although the cell I am placing is an annotation cell its being placed at its original scale which is set as Point3dFromXYZ(1,1,1). I can select all instances after placement and use the key-in ANNOTATIONSCALE ADD and the cells increase to the correct scale. I've read 'Annotation Scale for Elements' in VBA help and have attempted to apply annotation scale prior to placing the cell but it errors

    Set oCell = CreateCellElement2(cellName, pts(N), Point3dFromXYZ(1,1,1), True, matrix)

'added the following 4 lines to attempt to apply annotation scale prior to placement
    Dim propH                                As PropertyHandler
    Set propH = CreatePropertyHandler(oCell)
    propH.SelectByAccessString ("UseAnnotationScale")
    propH.SetValue True

    oCell.graphicGroup = graphicGroup
    ActiveModelReference.AddElement oCell

First time encounter property handlers so I'm obviously making a fundamental mistake somewhere. Any pointers as how to solve my issue would be appreciated.

RE: [CONNECT VBA] GetCExpressionValue

$
0
0

The source code for GetCExpressionValue for both MicroStation V8i and CONNECT is identical - no changes to the topmost level of the functions.  If there is a specific use (or test) case you can point us to we can look into any behavior differences.

As for what MDL functions are published, the most common functions are decorated, exported, and given MDL context in stdmdlbltin.dll located in the product root directory.  Additional stdXxxx labeled dll libraries exist, though I cannot vouch that those method are accessible via CExpression at this time.

HTH,
Bob

[CONNECT VBA] GetCExpressionValue

$
0
0

A couple of posters have noted that VBA's GetCExpressionValue doesn't work in CONNECT as it worked in earlier versions of MicroStation.  Are C expressions fully-functional in CONNECT?  Are all MDL functions published?

RE: mdlMeasure_elmDscrArea : is this changed in connect version

$
0
0

[quote user="djeten"]cExpression = "mdlMeasure_elmDscrArea(" & VarPtr(area) & "," & VarPtr(perimeter) & "," & desc & ")"[/quote]

What could be happening is that the pointers are wrong.  VarPtr is an undocumented function in VBA (it's undocumented because Microsoft doesn't want to become involved in discussions like this).  It converts a VBA variable into a C address-of variable.  The problem you've encountered is that V8i is 32-bit whereas CONNECT is 64-bit.  In CONNECT, the MDL functions want 64-bit addresses.

Try changing VarPtr to LongPtr for CONNECT...

cExpression = "mdlMeasure_elmDscrArea(" & LongPtr(area) & "," & LongPtr(perimeter) & "," & desc & ")"

Having said that, I think Jan's suggestion to declare the MDL function and use it directly is better than burying it inside a C expression.

Viewing all 7260 articles
Browse latest View live


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