I am using OpenDesignFileForProgram and I am curious where it picks which Bentley Program to use to open the design file. I have V8i (SS4), CONNECT and AECOsim loaded and this always calls AECOsim. My file associations are set so that dgn files use SS4. Wear should I look in the registry?
What instance of microstation does opendesignfileforprogram use
[CONNECT SDK] Resource Compiler wacky failure
I want a ToggleButton resource that controls a flag to let the user turn on/off a fence. I gave the ToggleButton resource an ID, which I consider to be uncontroversial: TOGGLEBUTTONID_UseFence. The resource compiler barfs with this absurd message:
\sdk\examples\annotations\textexample\TextExampleIds.h(25): error C2059: syntax error: '(' \sdk\examples\annotations\textexample\TextExampleIds.h(25): error C3805: '(': unexpected token, expected either '}' or a ',' \sdk\examples\annotations\textexample\TextExampleIds.h(26): error C2143: syntax error: missing ')' before ';'
To produce this message, there are two requirements:
- The resource IDs are defined in an enumeration
- The resource ID alias includes characters _Use
For example, the following causes the compiler to emit the error message:
enum ToggleButtonIdsEnum { TOGGLEID_Uncontroversial = 10, TOGGLEID_UseFence, // => Compiler dislikes that name };
I attach a modified version of the SDK TextExample.
communities.bentley.com/.../TextExample.zip
All I've done is to add the above enumeration into TextExampleIds.h.
[CONNECT C#] Is there a way to close MicroStation from within an addin?
Is there a way to close MicroStation from within an addin? (Besides just finding all the running process an killing them all?)
How to change the element class of text by batch processing or macro?
Hi,
I try to change a couple of texts an data fields by batch processing and if possible also change the element class for these texts from construction to primary.
If it could be important to know, the texts are grouped!
Changing text and data fields works well with this batch command:
MDL SILENTLOAD FINDREPLACETEXT,CHNGTXT CHANGE DIALOGTEXT
FIND DIALOG SEARCHSTRING [old text]
FIND DIALOG REPLACESTRING [new text]
CHANGE TEXT ALLFILTERED
but I could not change the class in any way... :(
Is there a possibility to to that?
I tried also to do it by a macro.
The rename part works well again, but not the part for the element class :(
The additional code (red) for the class changing seems not to work
Sub main
Dim startPoint As MbePoint
Dim point As MbePoint, point2 As MbePoint
' Start a command
MbeSendCommand "MDL KEYIN FINDREPLACETEXT,CHNGTXT CHANGE DIALOGTEXT"
' Send a keyin that can be a command string
MbeSendKeyin "FIND DIALOG PAN True"
MbeSendKeyin "FIND DIALOG ZOOM True"
MbeSendKeyin "FIND DIALOG ZOOMLEVEL 14"
MbeSendKeyin "FIND DIALOG SEARCHSTRING "
MbeSendKeyin "FIND DIALOG SEARCHSTRING old Text"
MbeSendKeyin "FIND DIALOG REPLACESTRING new Text"
MbeSendKeyin "CHANGE TEXT ALLFILTERED"
MbeSendKeyin "FIND DIALOG SEARCHSTRING "
MbeSendKeyin "FIND DIALOG SEARCHSTRING new Text"
MbeSendCommand "ACTIVE CLASS PRIMARY "
MbeSendCommand "CHANGE CLASS "
End Sub
I have to change the content and class for 10 textes (always the same) on a lot of drawings.....
perhaps another idea to do that?
Thanks
Regards, Raphael
[CONNECT C++] Hatching an element of a cell
I've read a cell into an EditElementHandle and I want to pattern a component of the cell (an ellipse). I use a ChildEditElemIter to locate the ellipse to hatch. The hatch does not show up (I have fill and patterns turned on). I think this is because 1) the "spacing" is too large, or 2) My approach is wrong (I should clarify that the cell has NOT yet been written to the model):
private: void AddCrossHatching(EditElementHandleR eehCell) { ElementPropertiesGetterPtr propGetter = ElementPropertiesGetter::Create(eehCell); UInt32 color = propGetter->GetColor(); if (eehCell.GetElementType() == ELLIPSE_ELM && color == 1 ) { PatternParamsPtr params = PatternParams::Create(); params->SetPrimarySpacing(1.0); //UORs? params->SetPrimaryAngle(Angle::DegreesToRadians(45.0)); IAreaFillPropertiesEdit *patternEditP = dynamic_cast<IAreaFillPropertiesEdit*>(&eehCell.GetHandler()); bool bDidPattern = patternEditP->AddPattern(eehCell, *params, nullptr, 0); eehCell.ReplaceInModel(eehCell.GetElementRef()); } for (ChildEditElemIter child(eehCell); child.IsValid(); child = child.ToNext()) { AddCrossHatching(child); } }
[CONNECT C++] Hatching a newly created shape element
In my _OnDynamicFrame() method I create a shape element (ShapeHandler::CreateShapeElement()) and then I use IAreaFillPropertiesEdit to AddPattern(). When that EditElementHandle is drawn (RedrawElems::DoRedraw()) the shape element appears without the hatching. However, if I call AddToModel() on the EditElementHandle while in _OnDynamicFrame(), the hatching does "appear" on the shape(s) that are written to the model. Any way to get the pattern to dynamically display while in _OnDynamicFrame()?
Bruce
[CONNECT C++] General Questions About Hatching Implementation
How is hatching implemented? In a cell library I have created a simple cell and hatched an ellipse. When I try to analyze the contents of the model, I see nothing via Element Information or Analyze Element that indicates the hatching is a pattern (no linkages or XAttributes). I *do* see that all the "pattern" elements have the same "GraphicGroup" value. Yet, when I read that cell into memory (in my tool), I can get the IAreaFillPropertiesEdit of the element the hatching was applied against, so somehow the element is flagged that it has a fill/hatching. Trying to iterate the cell, find the element that has the fill/hatching, and "removing" it (IAreaFillPropertiesEdit::RemovePattern()) fails (Getting the handler succeeds, but removing the pattern fails). I guess one could remove the cell elements based on the GraphicGroup value, but what affect does that have on the "tie" back to the host element (the element originally used for the hatching)?
Bruce
[Connect U9 C#] CentroidNormalArea returning area scaled by 2xUorPerMaster
CurveVector.CentroidNormalArea seems to be returning 2xUorPerMaster
See code below..
I Created 10x10 square.
With 1 call to FromUor() I get "304800.0000"
With 2 calls, I get the expected "100.0"
I also called element.AddToModel() to make sure that I had not scaled by element by 2x UorPerMaster, and it falls in the correct place.
using (CurveVector curveVector = CurvePathQuery.ElementToCurveVector(element)) { if (curveVector.IsClosedPath || curveVector.IsParityRegion || curveVector.IsUnionRegion) { DPoint3d centroid; double area; DVector3d normal; if (curveVector.CentroidNormalArea(out centroid, out normal, out area)) return area.FromUor().FromUor(); // Two FromUor calls required to return the proper area } } public static double FromUor(this double d) { DgnModel model = Ms.GetActiveModel(); ModelInfo mInfo = model.GetModelInfo(); double scale = mInfo.UorPerMaster; return d / scale; }
Is the there a way of getting a list of reference files that are attached to a given design file without loading the deign files using a Java API?
I would like to retrieve all reference files from a PID file. Using command prompt -wref open microstation text window, from there it is not possible to read the output from Java desktop application. Anyone can give me any idea to get those reference file list in a Java desktop application. Any reference to vbscript also help.
[VBA PowerInroads SS4] how to detect no active font
Hi All,
I am probably not using the correct terminology when saying "active font," so let me describe what's happening. Last year they gave me a new computer and so I got upgraded from Microstation SS2 to PowerInroads SS4. When they did that, they updated my seed files and a lot of other stuff. One thing I noticed about the new seed files was that some of my macros no longer worked. I tracked down the problem to not having an "active font" chosen in the seed file. My solution was to go to the Place Text tool and choose a font and save the settings. It was an easy work around, so I just left it like that. Now I have more time, I'd like to put in a programmatic solution to handle this situation. The problem is I don't know how to correctly detect when there is no " active font." I did come up with a routine that works, but it is such a kludge, even by my standards, that I thought I'd ask you how to properly do it.
Public Function IsNoActiveFont() As Boolean On Error GoTo errhnd Dim myfont As Font Set myfont = ActiveSettings.TextStyle.Font IsNoActiveFont = False Exit Function errhnd: IsNoActiveFont = True End Function Public Sub test() If IsNoActiveFont() Then MsgBox "none" Else MsgBox "have font" End If End Sub
Thanks,
Minion
Using or retrieving information from existing Script Files
My example is this:
Sub A01set()
' 060618 - Set Level 1 with all selections 1, Testing
' Send a keyin that can be a command string
' CHANGE BELOW STATMENT TO COMMENT, was opening the key-in command
' CadInputQueue.SendKeyin "DIALOG CMDBROWSE"
CadInputQueue.SendKeyin "lv=1"
CadInputQueue.SendKeyin "co=1"
CadInputQueue.SendKeyin "lc=0"
CadInputQueue.SendKeyin "wt=1"
CadInputQueue.SendKeyin "m,ms 060618"
CommandState.StartDefaultCommand
End Sub
The above works fine, but hard to change on the fly. Meaning if a drawing comes in and Level 1 is color 3 I have scripts that contain current file settings and I touch a button and the key-in command runs the script. I have had times the script files are not working ?? but if I go to manual key-in commands
Example: lv=1;co=3;lc=0;wt=1 it will work when the same script file failed
Script Example:
Active Level Level 1
lc=0
wt=1
' active symbology bylevel
co=bylevel
So I was wondering if I used VBA to read the script and send the commands it would clearup the occasional failure ?
you can see the number keys, they set the level and the other attributes the lower row key is a pulldown of the script files and gives me direct access to the files and once per .dgn I may have to change color, or linestyle or weight . so I speed up the process by matching the script files to each .dgn not often changes but a time saver an only 1 change per drawing. I wondered if I used the VBA reading my scripts if it would avoid the few times the key-in seems to fail? I create on my time to improve my productivity or preformance.
I am not a programmer, I have tried the record but it will not seem to record some things. Jon I read some of your comments and if this has been discussed, please point me in the right direction.
[Connect C++] IElementGraphicsProcessor & Text color
I used IElementGraphicsProcessor to do text tessellation, one issue I find given above example, the tessellated text facet color seems confusing and the text's color can't be get:
in details for each text facet:
m_fillColor = displayParams.GetFillColor(); // always return INVALID_COLOR
m_lineColor = displayParams.GetLineColor(); // always return text background border color
For text facet I supposed should use the fill color? The fill color is INVALID so I don't know how to get the correct fill color. And the line color is always the border color which is not correct either.
Thanks,
Danny
[Connect API] Missing headers/declarations in SDK
Hi,
Does Bentley intend to fix this critical issue?
This issue was reported 29.12.2016.
It is very hard to believe that it takes more than 18 months to fix something important as this.
PointCloud is important part of API and it is not working.
thanks
Nenad
delete Drawn Line Element
Dear Guys
how can i delete Drawn Line Element with c#
thanks a lot
[CONNECT OpenPlant Modeler SDK Examples] pGetter.GetPropertyValue("LENGTH") return null
In NoteExample of the OpenPlant Modeler SDK examples, pGetter.GetPropertyValue("LENGTH") is returning null. Please see image of debug and exception that follows. This is consistent behavior for all examples containing pGetter.GetPropertyValue("LENGTH"). Note that pipeComponent has been created with a property "LENGTH" of 500.
Detaching references while leaving specific references
Hi,
I'm considering ways to streamline an internal process using Microstation V8i SS4.
During the process, we are required to remove all attached drawing references, except specific border ones we're required to use and raster images. These required border references will always be known and are consistent across the drawings. Currently we do this manually for every single drawing; however, I'm wondering if there's a way to use VBA or another solution (like Axiom tools) to accomplish this within a batch process.
For example, I have the following references/raster in two drawing files:
Drawing 1 has: RefA.dgn, RefB.dgn, RefC.dwg, RefD.dxf, & imgA.cit
Drawing 2 has: RefZ.dgn, RefE.dwg, RefF.dxf, & imgB.cit
Between the two files, I only want to keep the RefA.dgn & RefZ.dgn and the particular raster file each file has, but detach all other references.
I've been digging into IF, THEN, and ELSE statements usage within VBAs and quite frankly, I'm inexperienced with VBA. I'm not even sure if VBA allows OR statements either in the event I wish to specify multiple border reference filenames to keep.
So I guess I have a few questions:
1) Is this even possible to do with VBA?
2) Does VBA allow OR statements within IF statements?
VBA Microstation Connect object model
Can any one point me in the direction of the documentation for the Microstation VBA object model for Connect edition?
add text to a point
Dear Guys
i am using MicroStation V8i 2008 Edition and my code is MicroStatio addin .
i wanna add text to PointElement position with c# , what should i do?
thanks a lot
[CONNECT C++] FenceParams::Create and ::Delete
Why, in a C++ API, do we have static methods FenceParams::Create
and FenceParams::Delete
to manage memory allocation and de-allocation of abstract class FenceParams
? Why doesn't FenceParams
derive from RefCountedPtr
?
Rotation and transformation matrix
Hi,
I'm struggling with placing a cell along an arc in VBA.
I have a Complex Chain where I will place a cell along the whol chain with a fixed distance.
I have solved the rotation on the "Line" part of the chainm but having trouble with the arc.
The rotation is almost correct, but almost doesn't count :-)
Any one have a suggestion?
The code snippet for placing the cell:
Sub showLineElm(LinElm As ComplexStringElement)
Dim elm As ElementEnumerator
Dim aelm As ArcElement
Dim lelm As LineElement
Dim oPH As PropertyHandler
Dim lastsegment As String
Dim streng As String, streng1 As String
Dim start As Point3d
Dim skala As Point3d
Dim oCell As CellElement
Dim z As Integer
Dim ant_cell As Double, distance As Double
Dim vinkel As Double
Dim mtrxRotation As Matrix3d
skala.X = 1
skala.Y = 1
skala.z = 1
If LinElm.Type = msdElementTypeComplexString Then
If LinElm.IsTraversableElement Then
Set elm = LinElm.GetSubElements
Do While elm.MoveNext
Select Case elm.Current.Type
Case msdElementTypeLine
Set lelm = elm.Current.AsLineElement
lastsegment = "Segments[" & (lelm.VerticesCount - 2) & "]."
Set oPH = CreatePropertyHandler(lelm)
oPH.SelectByAccessString (lastsegment & "Start")
start = oPH.GetValueAsPoint3d
oPH.SelectByAccessString (lastsegment & "Direction")
streng = oPH.GetValue
vinkel = Degrees(CDbl(streng))
mtrxRotation = Matrix3dFromAxisAndRotationAngle(2, CDbl(streng))
Set oCell = CreateCellElement2("cellname", start, skala, True, mtrxRotation)
ActiveModelReference.AddElement oCell
ant_cell = lelm.Length / 0.854
ant_cell = ant_cell \ 1
distance = 0
For z = 1 To ant_cell
distance = distance + 0.854
If distance > lelm.Length Then
Exit For
End If
start = lelm.PointAtDistance(distance)
Set oCell = CreateCellElement2("cellname", start, skala, True, mtrxRotation)
ActiveModelReference.AddElement oCell
Next z
Case msdElementTypeArc
Set aelm = elm.Current.AsArcElement
Set oPH = CreatePropertyHandler(aelm)
oPH.SelectByAccessString ("SweepAngle")
vinkel = oPH.GetValue
mtrxRotation = Matrix3dFromAxisAndRotationAngle(2, vinkel)
start = aelm.StartPoint
Set oCell = CreateCellElement2("cellname", start, skala, True, mtrxRotation)
distance = 0
oCell.Transform Transform3dFromMatrix3dAndFixedPoint3d(mtrxRotation, start)
ActiveModelReference.AddElement oCell
ant_cell = aelm.Length / 0.854
ant_cell = ant_cell \ 1
For z = 1 To ant_cell
distance = distance + 0.854
If distance > aelm.Length Then
Exit For
End If
start = aelm.PointAtDistance(distance)
Set oCell = CreateCellElement2("cellname", start, skala, True, mtrxRotation)
oCell.Transform Transform3dFromMatrix3dAndFixedPoint3d(mtrxRotation, start)
ActiveModelReference.AddElement oCell
Next z
End Select
Loop
End If
End If
errExit:
End Sub 'showLineElm