Loading Printing Set.

Loading Printing Set.

Anonymous
Not applicable
582 Views
5 Replies
Message 1 of 6

Loading Printing Set.

Anonymous
Not applicable

 Hi All,

 

Any idea about how to set existing printing set as active printing set after clicked from combo box list.

 

adk.PNG

it is succussfully loading all existing printing set in cobo box but bit confused in set as active printing set in api.

Thanks in advance.

 

Regards

Mass.R

0 Likes
Accepted solutions (1)
583 Views
5 Replies
Replies (5)
Message 2 of 6

Mustafa.Salaheldin
Collaborator
Collaborator

I guess you need to use PrintSetup.CurrentPrintSetting property.


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

0 Likes
Message 3 of 6

Anonymous
Not applicable

Hi Thanks for reply,

 

By using this code i am accessing all printing set can you tell me where can i change the printing setting.

 

List<string> list = new List<string>();
IList<ViewSheetSet> vsheetsets = new FilteredElementCollector(document)
.OfClass(typeof(ViewSheetSet)).Cast<ViewSheetSet>().ToList();
foreach(ViewSheetSet vs in vsheetsets)
{
if (!comboBox1.Items.Contains(vs.Name)) comboBox1.Items.Add(vs.Name);
}

 

0 Likes
Message 4 of 6

Mustafa.Salaheldin
Collaborator
Collaborator
Accepted solution

For the form code:

 

using Autodesk.Revit.DB;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RevitAddinCS5
{
    public partial class Form1 : System.Windows.Forms.Form
    {
        Document _CachedDoc;

        public Form1(Document CachedDoc)
        {
            InitializeComponent();
            _CachedDoc = CachedDoc;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            List<string> list = new List<string>();
            List<ViewSheetSet> vsheetsets = new FilteredElementCollector(_CachedDoc)
            .OfClass(typeof(ViewSheetSet)).Cast<ViewSheetSet>().ToList();

            BindingSource bindingSource1 = new BindingSource();
            bindingSource1.DataSource = vsheetsets;
            
            cb.DataSource = bindingSource1.DataSource;
            cb.DisplayMember = "Name";
            cb.ValueMember = "Views";

        }

        private void Print_Click(object sender, EventArgs e)
        {
            try
            {
                PrintManager printManager = _CachedDoc.PrintManager;
                printManager.PrintRange = PrintRange.Select;
                ViewSheetSetting viewSheetSetting = printManager.ViewSheetSetting;
                viewSheetSetting.CurrentViewSheetSet.Views = cb.SelectedValue as ViewSet;
                printManager.SubmitPrint();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}

 

For the External Command:

 

#region Namespaces

using System;
using System.Text;
using System.Linq;
using System.Xml;
using System.Reflection;
using System.ComponentModel;
using System.Collections;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Media.Imaging;
using System.Windows.Forms;
using System.IO;

using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;

using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Events;
using Autodesk.Revit.DB.Architecture;
using Autodesk.Revit.DB.Structure;
using Autodesk.Revit.DB.Mechanical;
using Autodesk.Revit.DB.Electrical;
using Autodesk.Revit.DB.Plumbing;

using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using Autodesk.Revit.UI.Events;

//using Autodesk.Revit.Collections;
using Autodesk.Revit.Exceptions;
using Autodesk.Revit.Utility;

using RvtApplication = Autodesk.Revit.ApplicationServices.Application;
using RvtDocument = Autodesk.Revit.DB.Document;

#endregion

namespace RevitAddinCS5
{
    [Transaction(TransactionMode.Manual)]
    [Regeneration(RegenerationOption.Manual)]
    public class ExtCmd : IExternalCommand
    {
        #region Cached Variables

        private static ExternalCommandData _cachedCmdData;

        public static UIApplication CachedUiApp
        {
            get
            {
                return _cachedCmdData.Application;
            }
        }

        public static RvtApplication CachedApp
        {
            get
            {
                return CachedUiApp.Application;
            }
        }

        public static RvtDocument CachedDoc
        {
            get
            {
                return CachedUiApp.ActiveUIDocument.Document;
            }
        }

        #endregion

        #region IExternalCommand Members

        public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elemSet)
        {
            _cachedCmdData = cmdData;

            try
            {
                Form1 frm = new Form1(CachedDoc);
                frm.Show();


                return Result.Succeeded;
            }
            catch (Exception ex)
            {
                msg = ex.ToString();
                return Result.Failed;
            }
        }

        #endregion
    }
}

 

If this works fine with you don't forget to mark the reply as an answer.


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

Message 5 of 6

Anonymous
Not applicable

If you dont can you attach the VS file for my reference and it will help me alot to understand more about coding.

0 Likes
Message 6 of 6

Mustafa.Salaheldin
Collaborator
Collaborator

Here you are Smiley Very Happy


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn