internal SwFeatureDimensionsEnumerator(IFeature feat, ISwDocument doc, ISwApplication app) { m_Doc = doc; m_Feat = feat; m_App = app; m_IsStart = true; }
internal SwSketch3D(IFeature feat, ISwDocument doc, ISwApplication app, bool created) : base(feat, doc, app, created) { if (doc == null) { throw new ArgumentNullException(nameof(doc)); } }
public ISwModelViewTab <TControl> CreateDocumentTab <TControl>(ISwDocument doc) { var mdlViewMgr = doc.Model.ModelViewManager; return(CustomControlHelper.HostControl <TControl, SwModelViewTab <TControl> >( (c, h, t, _) => { if (mdlViewMgr.DisplayWindowFromHandlex64(t, h.Handle.ToInt64(), true)) { return new SwModelViewTab <TControl>(c, t, mdlViewMgr, (SwDocument)doc, Logger); } else { throw new NetControlHostException(h.Handle); } }, (p, t, _) => { var ctrl = (TControl)mdlViewMgr.AddControl3(t, p, "", true); if (ctrl == null) { throw new ComControlHostException(p); } return new SwModelViewTab <TControl>(ctrl, t, mdlViewMgr, (SwDocument)doc, Logger); })); }
internal SwConfiguration(ISwDocument doc, IConfiguration conf) : base(conf) { m_Doc = doc; m_Conf = conf; Properties = new SwCustomPropertiesCollection(m_Doc, Name); }
internal SwObject(object disp, ISwDocument doc, ISwApplication app) { Dispatch = disp; m_TagsLazy = new Lazy <ITagsManager>(() => new TagsManager()); OwnerDocument = doc; OwnerApplication = app; }
internal SwSketchEntityCollection(ISwDocument doc, ISwSketchBase sketch) { m_Doc = doc; m_Sketch = sketch; m_SkMgr = doc.Model.SketchManager; m_Cache = new List <IXSketchEntity>(); }
public override CustomFeatureRebuildResult OnRebuild(ISwApplication app, ISwDocument model, ISwMacroFeature feature) { return(new CustomFeatureRebuildResult() { Result = true }); }
public void Init(IXApplication app, IXDocument model) { Document = (ISwDocument)model; Application = ((ISwApplication)app).Sw; OnInit((ISwApplication)app, Document); Model = Document.Model; switch (Model) { case PartDoc part: AttachPartEvents(part); break; case AssemblyDoc assm: AttachAssemblyEvents(assm); break; case DrawingDoc drw: AttachDrawingEvents(drw); break; default: throw new NotSupportedException("Not a SOLIDWORKS document"); } }
//--- StorageLoad private void LoadFromStorageStore(ISwDocument model) { using (var storage = model.TryOpenStorage(STORAGE_NAME, AccessType_e.Read)) { if (storage != null) { using (var str = storage.TryOpenStream(STREAM1_NAME, false)) { if (str != null) { var xmlSer = new XmlSerializer(typeof(StorageStreamData)); m_StorageData = xmlSer.Deserialize(str) as StorageStreamData; } } using (var subStorage = storage.TryOpenStorage(SUB_STORAGE_NAME, false)) { if (subStorage != null) { using (var str = subStorage.TryOpenStream(STREAM2_NAME, false)) { if (str != null) { var buffer = new byte[str.Length]; str.Read(buffer, 0, buffer.Length); var dateStr = Encoding.UTF8.GetString(buffer); var date = DateTime.Parse(dateStr); } } } } } } }
internal SwSketch2D(ISwDocument doc, IFeature feat, bool created) : base(doc, feat, created) { if (doc == null) { throw new ArgumentNullException(nameof(doc)); } }
internal SwCustomPropertiesCollection(ISwDocument doc, string confName) { m_Doc = doc; m_EventsHelper = new CustomPropertiesEventsHelper(doc.App.Sw, doc); m_ConfName = confName; }
internal SwSketchEntitiesEnumerator(ISwDocument doc, ISwSketchBase sketch) { m_Doc = doc; m_Sketch = sketch; m_Entities = new List <object>(); Reset(); }
//--- //--- StreamSave private void SaveToStream(ISwDocument model) { using (var str = model.OpenStream(STREAM_NAME, AccessType_e.Write)) { var xmlSer = new XmlSerializer(typeof(StreamData)); xmlSer.Serialize(str, m_StreamData); } }
public override CustomFeatureRebuildResult OnRebuild(ISwApplication app, ISwDocument model, ISwMacroFeature feature) { return(new CustomFeatureRebuildResult() { Result = false, ErrorMessage = "Failed to regenerate this feature" }); }
public override CustomFeatureRebuildResult OnRebuild(ISwApplication app, ISwDocument model, ISwMacroFeature feature, EditMacroFeatureDefinitionParameters parameters, out AlignDimensionDelegate <EditMacroFeatureDefinitionParameters> alignDim) { alignDim = null; return(new CustomFeatureRebuildResult() { Result = true }); }
internal SwSketchEllipse(ISketchEllipse ellipse, ISwDocument doc, ISwApplication app, bool created) : base((ISketchSegment)ellipse, doc, app, created) { if (doc == null) { throw new ArgumentNullException(nameof(doc)); } }
public override CustomFeatureRebuildResult OnRebuild(ISwApplication app, ISwDocument model, ISwMacroFeature feature, MacroFeatureParams parameters, out AlignDimensionDelegate <MacroFeatureParams> alignDim) { var txt = parameters.TextParameter; var inputBody = parameters.InputBody; alignDim = null; return(new CustomFeatureRebuildResult()); }
public override ISwBody[] CreateGeometry(ISwApplication app, ISwDocument model, ShaftChamferData data, bool isPreview, out AlignDimensionDelegate <ShaftChamferData> alignDim) { var dir = data.Edge.AdjacentEntities.OfType <ISwPlanarFace>().First().Definition.Plane.Normal * -1; var centerPt = data.Edge.Definition.Center; var largeRad = data.Edge.Definition.Diameter / 2; if (data.Radius >= largeRad) { throw new Exception($"Specified radius must not exceed {Math.Round(largeRad * 1000, 2)} mm"); } var x = largeRad - data.Radius; var height = x / Math.Tan(data.Angle); var coneBody = (ISwBody)(app.MemoryGeometryBuilder.CreateSolidCone(centerPt, dir, data.Radius * 2, largeRad * 2, height).Bodies.First()); var cylBody = (ISwBody)(app.MemoryGeometryBuilder.CreateSolidCylinder(centerPt, dir, largeRad * 2, height).Bodies.First()); var targBody = data.Body; if (isPreview) { targBody = targBody.ToTempBody(); } var result = targBody.Substract(cylBody.Substract(coneBody).First()).First(); alignDim = new AlignDimensionDelegate <ShaftChamferData>((p, d) => { switch (p) { case nameof(data.Radius): this.AlignRadialDimension(d, centerPt, dir); break; case nameof(data.Angle): Vector refVec; var yVec = new Vector(0, 1, 0); if (dir.IsSame(yVec)) { refVec = new Vector(1, 0, 0); } else { refVec = yVec.Cross(dir); } var refPt = centerPt.Move(refVec, largeRad); var anglCenterPt = refPt.Move(dir, height); this.AlignAngularDimension(d, anglCenterPt, refPt, dir.Cross(refVec)); break; } }); return(new ISwBody[] { result }); }
protected virtual void AddDataToRebuildQueue(ISwApplication app, ISwDocument doc, ISwMacroFeature macroFeatInst) { m_RebuildFeaturesQueue.Add(new MacroFeatureRegenerateData() { Application = app, Document = doc, Feature = macroFeatInst }); }
private ISwDocument GetTempDocument() { if (!IsTempDocAlive()) { m_TempDoc = CreateTempDocument(); } return(m_TempDoc); }
protected SwSketchSegment(ISwDocument doc, ISketchSegment seg, bool created) : base(doc, seg) { if (doc == null) { throw new ArgumentNullException(nameof(doc)); } m_SketchMgr = doc.Model.SketchManager; m_Creator = new ElementCreator <ISketchSegment>(CreateEntity, seg, created); }
internal SwBoundingBox(ISwDocument doc, ISwApplication app) { m_Doc = doc; m_MathUtils = app.Sw.IGetMathUtility(); m_Creator = new ElementCreator <EditableBox3D>(CreateBox, null, false); UserUnits = false; }
public ISwFeatureMgrTab <TControl> CreateFeatureManagerTab <TControl>(ISwDocument doc) { var tab = new SwFeatureMgrTab <TControl>( new FeatureManagerTabCreator <TControl>(doc.Model.ModelViewManager, m_SvcProvider), (SwDocument)doc, Logger); tab.InitControl(); return(tab); }
public override CustomFeatureRebuildResult OnRebuild(ISwApplication app, ISwDocument model, ISwMacroFeature feature) { var body = app.MemoryGeometryBuilder.CreateSolidBox(new Point(0, 0, 0), new Vector(1, 0, 0), new Vector(0, 1, 0), 0.1, 0.1, 0.1); return(new CustomFeatureBodyRebuildResult() { Bodies = body.Bodies.ToArray() }); }
//--- StreamLoad private void LoadFromStream(ISwDocument model) { using (var str = model.TryOpenStream(STREAM_NAME, AccessType_e.Read)) { if (str != null) { var xmlSer = new XmlSerializer(typeof(StreamData)); m_StreamData = xmlSer.Deserialize(str) as StreamData; } } }
internal SwFeature(IFeature feat, ISwDocument doc, ISwApplication app, bool created) : base(feat, doc, app) { if (doc == null) { throw new ArgumentNullException(nameof(doc)); } Dimensions = new SwFeatureDimensionsCollection(this, OwnerDocument, OwnerApplication); m_Creator = new ElementCreator <IFeature>(CreateFeature, feat, created); }
public override ISwBody[] CreateGeometry(ISwApplication app, ISwDocument model, BoxMacroFeatureData data, bool isPreview, out AlignDimensionDelegate <BoxMacroFeatureData> alignDim) { alignDim = null; var box = (ISwBody)app.MemoryGeometryBuilder.CreateSolidBox( new Point(0, 0, 0), new Vector(0, 0, 1), new Vector(1, 0, 0).CreateAnyPerpendicular(), data.Width, data.Height, data.Length).Bodies.First(); return(new ISwBody[] { box }); }
internal SwFeature(ISwDocument doc, IFeature feat, bool created) : base(feat, doc) { if (doc == null) { throw new ArgumentNullException(nameof(doc)); } Dimensions = new SwFeatureDimensionsCollection(m_Doc, this); m_Creator = new ElementCreator <IFeature>(CreateFeature, feat, created); }
internal SwCutListItem(ISwDocument doc, IFeature feat, bool created) : base(doc, feat, created) { if (feat.GetTypeName2() != "CutListFolder") { throw new InvalidCastException("Specified feature is not a cut-list feature"); } CutListBodyFolder = (IBodyFolder)feat.GetSpecificFeature2(); m_Properties = new Lazy <ISwCustomPropertiesCollection>( () => CreatePropertiesCollection()); }
internal SwDimension(IDisplayDimension dispDim, ISwDocument doc, ISwApplication app) : base(dispDim, doc, app) { if (doc == null) { throw new ArgumentNullException(nameof(doc)); } DisplayDimension = dispDim; m_ValueChangedHandler = new SwDimensionChangeEventsHandler(this, doc); }