Dear all,
i'am setting my Attachments with a Command:
Set oReferenz = oReferenzen.AddCoincident1(RefFile, "", "", "", msdAddAttachmentFlagCoincidentWorld)
In MSTN 8i was tested whether a Reffile is already attached. In this case i've got oReferenz is Nothing and a Error -2147220766.In a MSTN Connect i am getting a same Attachment with a Suffix Ref, without any Errors.
My Standardsetting for Loading of Attachments is: MS_REF_DEFAULTSETTINGS=display=1,snap=1,locate=1,treatAsElement=0,trueScale=1,useLights=0,saveRelativePath=0,scaleLineStyles=1,ignoreWhenNesting=0,displayRasterRefs=0,newLevelDisplay=fromconfig,nestMode=none,nestDepth=1,nestOverrides=allow,useAnnotationscale=1,plotAs3D=0
How can i prevent of attach the same attachment (which means the same model from the same design file) what is already attached in MSTN Connect?
Thank you.
A user can attach the same file/model multiple times, but each attachment must have a unique Logical Name: Since the same model can be attached many times, the logical name helps you distinguish between references.
Mikha Zaslavskiy said:Set oReferenz = oReferenzen.AddCoincident1(RefFile, "", "", "", msdAddAttachmentFlagCoincidentWorld)
An empty string is a valid Logical Name — as long as no other attachment has the same (empty string) as its logical name. If a model is already attached, and the user has assigned a Logical Name that is not an empty string, then your VBA statement above will succeed, because you are using an empty string for the Logical Name.
Regards, Jon Summers LA Solutions
Hi Jon,
i have tried it with a not empty Logical Name. Vba Statement was not succeed. Regards Mikha.
For Example:Set oReferenz = oReferenzen.AddCoincident1(RefFile, vbNullString, "TSW", "True Scale World", msdAddAttachmentFlagCoincidentWorld)
Mikha Zaslavskiy said:Set oReferenz = oReferenzen.AddCoincident1(RefFile, vbNullString, "TSW",
Attaches a reference using the default model of the specified file with logical name TSW.
Sorry Jon, what are you menaing with unique? I TRYED TO attachTHE EXISTING FILE WITH MY FANTASY LOGICAL NAME. I Dont know whether it is unique. After that i see my first Attachment with a new Logical Name "TSW".
Mikha Zaslavskiy said:what are you menaing with unique?
Whatever MicroStation means by unique! All that means is that if a DGN model is attached multiple times as a reference, each attachment must have a Logical Name that is different to all other Logical Names assigned to that model.
If one attachment has Logical Name FANTASY LOGICAL NAME, then no other attachment of the same model may have Logical Name FANTASY LOGICAL NAME. Since an empty string (VBA vbNullString or "") is a valid Logical Name, no two attachments of the same model may have Logical Name="".
vbNullString
""
Ok John thanks. I will check it, but why it was succeed in MSTN 8i and now in MSTN CE not? IN EXTREMELY I WILL SOLVE THIS THROUGH COLLECTION AND COMPARISON OF FILES. With Regards Mikha.
Jon Summers said:Whatever MicroStation means by unique!
This rule (how logical names work) is not understood right often, so I'd like to provide different formulation:
Regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Mikha Zaslavskiy said:IN EXTREMELY I WILL SOLVE THIS THROUGH COLLECTION AND COMPARISON OF FILES.
In my opinion it is the only way how to write correct code.
I do not understand why the problem of unique logical names is discussed so widely when it does not solve anything, because does not allow to implement robust code to test whether the same model is attached or not.
It's not the role of logical names and such code is useless, because it works only when (weak) assumption, that existing attachment has no logical name assigned, is true. When a model will be attached with logical name assigned, to attach the same model with empty logical name will (I guess) work fine and the model will be attached.
Mikha Zaslavskiy said:but why it was succeed in MSTN 8i and now in MSTN CE not?
My experience is that when VBA code from V8i is correct and clean, it runs fine (nearly) always in CE.
When problems appear, I have seen so far these sources of problems:
With regards,