TheSwamp

Code Red => .NET => Topic started by: pBe on May 12, 2016, 02:17:50 AM

Title: Access to Sheet Set components
Post by: pBe on May 12, 2016, 02:17:50 AM
What is the equivalent of vla-item in .NET

Code - C#: [Select]
  1.      
  2.             // Get a reference to the Sheet Set Manager object
  3.             IAcSmSheetSetMgr sheetSetManager = default(IAcSmSheetSetMgr);
  4.             sheetSetManager = new AcSmSheetSetMgr();
  5.  
  6.             // Open a Sheet Set file
  7.             AcSmDatabase sheetSetDatabase = default(AcSmDatabase);
  8.             sheetSetDatabase = sheetSetManager.OpenDatabase(DSTPath, true);
  9.  
  10.             // Get the sheet set from the database
  11.             AcSmSheetSet sheetSet = sheetSetDatabase.GetSheetSet();    
  12.  
  13.           AcSmSubset = < I  know the name of the subset >
  14.  
  15.  

< That > is the part where i'm stumped.
How do you access a Subset of a known "name": subset on a sheet set? similar to  (vla-item SheetSetCollection "Irrigation")
Code - C#: [Select]
  1.                 AcSmSubset subset = default(AcSmSubset);
  2.                 subset = (sheetSetDatabase.GetName(), SubsetName);
Thank you

pBe
Title: Re: Access to Sheet Set components
Post by: n.yuan on May 12, 2016, 10:23:09 AM
Look into:

AcSmSheetSet.GetSheetEnumerator() method, which returns an IAcSmEnumComponent. Something like:

var iterator = sheetSet.GetSheetEnumerator()

var sheet=iterator.Next() as AcSmSheet
while (sheet!=null)
{
    //Do somethign with the sheet
    ....
    iterator.Next()
}

Title: Re: Access to Sheet Set components
Post by: nobody on May 13, 2016, 01:10:47 AM
What is the equivalent of vla-item in .NET

Not sure anything is equal between the two.  For me, maybe a close equal to a vlax dump would be the intellisense in Visual Studio.  Had to break my brain to learn .Net after using lisp for so many years.
Title: Re: Access to Sheet Set components
Post by: ChrisCarlson on May 13, 2016, 07:59:28 AM
I didn't think you could access the SSM from Lisp?
Title: Re: Access to Sheet Set components
Post by: dgorsman on May 13, 2016, 10:15:29 AM
There are tons of equivalencies of (vla-Item ...) in dotNET.  The function is used to get an entry from an indexed collection, similar to an Item() or ElementAt() method.  In dotNET the method of accessing a collection will depend on the type of collection.
Title: Re: Access to Sheet Set components
Post by: nobody on May 14, 2016, 08:03:41 PM
A good example of using .net with sheet sets:

http://adndevblog.typepad.com/autocad/2013/09/using-sheetset-manager-api-in-vbnet.html
Title: Re: Access to Sheet Set components
Post by: pBe on May 23, 2016, 10:01:43 AM
Thank you for that Area51Visitor.

I have this to retrieve the Sheet Set ObjectID.

Code - C#: [Select]
  1.    
  2.     [CommandMethod("RetriveInfoSSM")]
  3.         public void RetriveInfoSSM()
  4.         {
  5.  
  6.             IAcSmSheetSetMgr sheetSetManager = default(IAcSmSheetSetMgr);
  7.             sheetSetManager = new AcSmSheetSetMgr();
  8.  
  9.             AcSmDatabase sheetSetDatabase = default(AcSmDatabase);
  10.             sheetSetDatabase = sheetSetManager.OpenDatabase("Z:\\Placholder\\Sheet Set Template.dst", false);
  11.  
  12.             MessageBox.Show(sheetSetDatabase.GetObjectId().GetHandle());
  13.  
  14.             sheetSetManager.Close(sheetSetDatabase);
  15.         }
  16.  

Question:
Instead of MessageBox.Show, is there way to pass the value to a variable that will be available upon command exit?

Look into:

AcSmSheetSet.GetSheetEnumerator() method, which returns an IAcSmEnumComponent. Something like:........


I'm still working on this one :). From what I've gathered . IAcSmEnumComponent is indeed the way to go about it.


Title: Re: Access to Sheet Set components
Post by: nobody on May 23, 2016, 10:24:42 PM
I'm assuming pass it so you can use it with autolisp. Correct me if I'm wrong. 
I've not done that myself but my gut tells me to use currentDocument.SendStringToExecute() but the formatting will be a bit tricky...see below for an example.
currentDocument.SendStringToExecute("(setq test (append test (list \"" + i.ToString() + "\")) ) ", true, false, false);

IMO this is like using a wrecking ball to do a hammers job. I can't stress how much I'd recommend pressing on with c# and .net though.  It's strange at first, the debug is a pain compared to writing directly in the command line with lisp, but in the end I think you'd find it hard to want to write in lisp again. dot-net just has too many benefits.

Quote
Question:
Instead of MessageBox.Show, is there way to pass the value to a variable that will be available upon command exit?
Title: Re: Access to Sheet Set components
Post by: pBe on May 24, 2016, 12:15:26 AM
I'm assuming pass it so you can use it with autolisp. Correct me if I'm wrong. 
I've not done that myself but my gut tells me to use currentDocument.SendStringToExecute() but the formatting will be a bit tricky...see below for an example.
currentDocument.SendStringToExecute("(setq test (append test (list \"" + i.ToString() + "\")) ) ", true, false, false);

Thank you for the tip.

IMO this is like using a wrecking ball to do a hammers job. I can't stress how much I'd recommend pressing on with c# and .net though.  It's strange at first, the debug is a pain compared to writing directly in the command line with lisp, but in the end I think you'd find it hard to want to write in lisp again. dot-net just has too many benefits.

Somehow I knew you're going to say that. :D, I started watching video tutorials of C# by Bob Tabor [Channel 9] and browse thru Little Wonder series. by James Michael Hare posted by Kerry, and I also bought a book by Pat McGee and i like what I'm seeing.

But right now, the program is 90 % done < in lisp >, I just need to run a program with the HELP of .NET. on the 10% [ Sheet Set side of things ]. so please bear with me with on this.

I will definitely re-write the whole thing when I know enough .NET.

Thank you for all your help.
Title: Re: Access to Sheet Set components
Post by: pBe on May 24, 2016, 01:29:14 AM
Thank you Area51visitor, SendStringToExecute works.

Code - Text: [Select]
  1. string Tolisp = sheetSetDatabase.GetObjectId().GetHandle();
  2. acDoc.SendStringToExecute("(_fromNet \"" + Tolisp +"\") ", true, false, false);
Title: Re: Access to Sheet Set components
Post by: nobody on May 24, 2016, 04:42:48 AM
Glad it worked!

Thank you Area51visitor, SendStringToExecute works.

Code - Text: [Select]
  1. string Tolisp = sheetSetDatabase.GetObjectId().GetHandle();
  2. acDoc.SendStringToExecute("(_fromNet \"" + Tolisp +"\") ", true, false, false);
Title: Re: Access to Sheet Set components
Post by: pBe on May 24, 2016, 07:45:16 AM
Code - Text: [Select]
  1. AcSmCustomPropertyValue SSMCustValue = new AcSmCustomPropertyValue();
  2. SSMCustValue.GetValue();

Why am I getting a value of  System.__ComObject ?

Apparently the value is a variant

Tried
Code - Text: [Select]
  1.  SSMCustValue.ToString();

Same result though.

Code - Text: [Select]
  1. SSMCustValue.GetValue().ToString()

Crashed !

Any thoughts?
Title: Re: Access to Sheet Set components
Post by: pBe on May 25, 2016, 06:34:32 AM
As it turned out, I just need to add MicrosoftCSharp.DLL to "Reference" , Saw the error message on Error List window.

and use GetValue() without the .ToString to get the string value

Code - Text: [Select]
  1.  SSMCustValue.GetValue()

All I need to do now is "Grab" the list from .Net and pass the values to lisp.....
Title: Re: Access to Sheet Set components
Post by: nobody on May 26, 2016, 03:21:33 AM
Nice. Glad you figured it out!