Hi there,
Is it possible to move reference elements to their new location one by one? If not, what should i do?
I'm trying following code but i couldn't success.
(I'm using V8i 08.11.05.17)
Option ExplicitDim EE As ElementEnumeratorDim SC As New ElementScanCriteriaDim elem As ElementDim i As LongDim a0 As Integer, a1 As Integer, a2 As IntegerDim b0 As Integer, b1 As Integer, b2 As Integera0 = 30a1 = 1a2 = 0b0 = 180b1 = 0b2 = 1Dim oAttachment As AttachmentSC.ExcludeNonGraphicalSet EE = oAttachment.Scan(SC) Do While EE.MoveNext Set elem = EE.Current Select Case elem.Type Case msdElementTypeCellHeader Dim offset As Point3d Dim onc As Point3d Dim td As Point3d onc = elem.AsCellElement.Origin td.Y = a0 + a1 * onc.Y + b1 * onc.X td.X = b0 + b2 * onc.Y + a2 * onc.X offset.X = td.X - onc.X offset.Y = td.Y - onc.Y offset.Z = onc.Z elem.Move offset elem.Redraw elem.RewriteCase msdElementTypeLine Dim startof As Point3d Dim transtart As Point3d Dim oline As LineElement f = elem.AsLineElement.VerticesCount Set oline = elem.AsLineElement For i = 1 To f startof = oline.Vertex(i) transtart.Y = a0 + a1 * startof.Y + b1 * startof.X transtart.X = b0 + b2 * startof.Y + a2 * startof.X transtart.Z = startof.Z oline.ModifyVertex i - 1, transtart Next oline.Redraw oline.Rewrite Case Else MsgBox "Not defined object: " & elem.Type End Select LoopoAttachment.RewriteoAttachment.Redraw
Option Explicit
Dim EE As ElementEnumeratorDim SC As New ElementScanCriteria
Dim elem As ElementDim i As Long
Dim a0 As Integer, a1 As Integer, a2 As IntegerDim b0 As Integer, b1 As Integer, b2 As Integera0 = 30a1 = 1a2 = 0b0 = 180b1 = 0b2 = 1
Dim oAttachment As Attachment
SC.ExcludeNonGraphicalSet EE = oAttachment.Scan(SC) Do While EE.MoveNext Set elem = EE.Current Select Case elem.Type Case msdElementTypeCellHeader Dim offset As Point3d Dim onc As Point3d Dim td As Point3d onc = elem.AsCellElement.Origin td.Y = a0 + a1 * onc.Y + b1 * onc.X td.X = b0 + b2 * onc.Y + a2 * onc.X offset.X = td.X - onc.X offset.Y = td.Y - onc.Y offset.Z = onc.Z elem.Move offset elem.Redraw elem.Rewrite
Case msdElementTypeLine Dim startof As Point3d Dim transtart As Point3d Dim oline As LineElement f = elem.AsLineElement.VerticesCount Set oline = elem.AsLineElement For i = 1 To f startof = oline.Vertex(i) transtart.Y = a0 + a1 * startof.Y + b1 * startof.X transtart.X = b0 + b2 * startof.Y + a2 * startof.X transtart.Z = startof.Z oline.ModifyVertex i - 1, transtart Next oline.Redraw oline.Rewrite
Case Else MsgBox "Not defined object: " & elem.Type End Select Loop
oAttachment.RewriteoAttachment.Redraw
Do you want to move the attached references or elements inside the attached references?
One thing I can see is you never set oAttachment to anything.
System: Win7 64bit 16GB Ram - microStation V8i SS3 08.11.09.578. + PoinTools CONNECT. - Intel i7-4800MQ CPU@2.70GHz, 4 core / 8 Logic proc.
Unknown said:Do you want to move the attached references or elements inside the attached references?
I want to move elements inside reference file.
cenber said:I want to move elements inside reference file
A reference attachment is read-only. That's the intent of references: they cannot be modified.
You can use OpenDesignFileForProgram to obtain programmatic access to a model. You can open a file for modification even if it is attached (read-only) as a reference.
Regards, Jon Summers LA Solutions
cenber said:td.Y = a0 + a1 * onc.Y + b1 * onc.X td.X = b0 + b2 * onc.Y + a2 * onc.X
It looks like you're attempting to transform elements. Why write your own transforms when MicroStation VBA provides an extensive API for object manipulation in 3D, including Transform3D?
Every graphic element has a Transform method, which takes a Transform3D as its argument.
Unknown said:You can use OpenDesignFileForProgram to obtain programmatic access to a model.
Thank you Jon, i will try this.
Best regards,
cenber