During the last days I noticed that one of my developers prepared a nice example that allows adding an additional hatch to a plan view section. The general steps are:

 

  • Creating one or more profiles that should be cutted
  • Adding a new section object for each sheet frame that should show the additional hatch

Attached also please find the final results as a file.

6a013483a6b06e970c0133f1f6150e970b-800wi

 

VBA source code:

 

Option Explicit

Public Sub GenerateAdditionalHatch()

Dim doc5 As LDX.LDXDocument

Dim app5 As LDX.LDXApplication

Set app5 = Application.Open(“LDX5”)

Set doc5 = app5.ActiveDocument

Calculate_ViewFrames2 doc5

doc5.CalculateModel rcmCalcAndReport Or rcmFireCalculatingEvent

End Sub

Private Sub Calculate_ViewFrames2(ByRef ld5Doc As LDX.LDXDocument)

Dim ldEntry As LDX.LDXEntry

Dim ldObj As LDX.LDXObject

Dim ldUComp As LDX.LDXUserComp

Dim ldProfile As LDX.LDXProfile

If ld5Doc.Shaft.GetEntries(1).Count = 0 Then Exit Sub

‘//////////////////////////////////////////////////////////////////////////////

‘create a user component with a simple profile

‘in general it will work with any profile, but the

‘”VolumeIndex” of the profile can be set only by programming code

‘//////////////////////////////////////////////////////////////////////////////

‘ get the first front entrance entrance

Set ldEntry = ld5Doc.Shaft.GetEntries(1).Item(0)

‘ create a user component if not yet existing

Set ldObj = ldEntry.Comp.Components.Item(“HatchTest.”)

If ldObj Is Nothing Then Set ldObj = ldEntry.Comp.Components.Add(“HatchTest.”)

Set ldUComp = ldObj.LDXType()

ldUComp.Comp.Object.ObjectMode = ldUComp.Comp.Object.ObjectMode And Not LDX.ObjectModes.obmInactive

With ldUComp.Comp.LocalMatrix.R

.X = 0

.Y = 0

.Z = 0

End With

‘ set or update the size of the first profile

Set ldProfile = ldUComp.Comp.Profiles.Item(0)

If ldProfile Is Nothing Then Set ldProfile = ldUComp.Comp.Profiles.InsertAt(0)

With ldProfile

.TYP = LDX.ProfileType.prtQ

.PG_P_DETAIL = 7

‘anything > 0, this number is important later in during cretaion oof the hatch section

.VolumeIndex = 1234

.PROFILE_MODE = LDX.ProfileModes.prmShaftAdd ‘important, otherwise it will not work

‘ some dimensions and sizes

.SetEquation LDX.ProfileEquationType.peqtB, CStr(ld5Doc.Shaft.Room.W_1)

.SetEquation LDX.ProfileEquationType.peqtH, CStr(ldEntry.WallOpening.T_AUSBR_B)

.SetEquation LDX.ProfileEquationType.peqtL, CStr(ldEntry.WallOpening.T_AUSBR_H)

.SetEquation LDX.ProfileEquationType.peqtLocalPositionX, CStr(ldEntry.WallOpening.XLEFT + 0.5 * ldEntry.WallOpening.T_AUSBR_B)

.SetEquation LDX.ProfileEquationType.peqtLocalPositionY, CStr(-0.5 * ld5Doc.Shaft.Room.W_1)

.SetEquation LDX.ProfileEquationType.peqtLocalPositionZ, CStr(0.5 * ldEntry.WallOpening.T_AUSBR_H)

.Comp.LocalMatrix.SetYz 0, 1, 0, 1, 0, 0

End With

Dim ldSheet As LDX.LDXSheet

Dim ldSheetFrame As LDX.LDXSheetFrame

‘find the proper section(s)

For Each ldSheet In ld5Doc.Sheets

For Each ldSheetFrame In ldSheet

‘ mark the section you want to update with this “Developer Name”

If ldSheetFrame.DeveloperName = “SPECIAL_HATCH” Then

Calculate_Hatch_For_Section ldSheetFrame

End If

Next

Next

End Sub

Private Sub Calculate_Hatch_For_Section(ByRef ldSheetFrame As LDX.LDXSheetFrame)

Dim ldFrameSections As LDX.LDXSheetFrameSections

Dim ldFrameSection As LDX.LDXSheetFrameSection

‘ get the additonal sections ( means hatches)

Set ldFrameSections = ldSheetFrame.Sections

ldFrameSections.Clear ‘ clear all of them

‘ add a new section (a new hatch)

Set ldFrameSection = ldFrameSections.Add() ‘es können auch mehrere Hatches für versch. Profile erzeugt werden

‘ set the parameters of the hatch

With ldFrameSection

.ANGLE = 30 ‘angle of hatch (s. viewframe Settings in LD)

.HATCH = “BRSTONE” ‘Name of the hatch (s. viewframe Settings in LD)

.Scale = 200 ‘Hatch scale (try what fits for your case)

‘Origin MUST intersect the profile, set .z for plan, for verticals you may set .X or .Y !!

.Origin.Z = ldSheetFrame.Comp.Object.Document.Shaft.GetEntries(1).Item(0).Comp.WorldMatrix.R.Z + 500

‘Volumeindex of the profiles tpo be cutted

.VOLUME_INDEX = 1234

.Normal.Z = -1 ‘view from top to bottom (plan view)

End With

Set ldFrameSection = Nothing

Set ldFrameSections = Nothing

End Sub

 

 

Download the related files here: Hatchsample.zip