.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Creating a MemberStyle

7 REPLIES 7
Reply
Message 1 of 8
Anonymous
310 Views, 7 Replies

Creating a MemberStyle

It's me again. I have a question about how to turn a Polyline that I was able to draw programmatically into a MemberStyle.

I want to be able to attach the MemberStyle to the Member with MemberType = Beam so that the profile of the Beam will be the Polyline that I drew. When I instatiate a MemberStyle variable, I don't see a function that converts the Polyline into the MemberStyle.

Thanks
Leonard
7 REPLIES 7
Message 2 of 8
Anonymous
in reply to: Anonymous

Look an example in a folder
C:\Program Files\AutoCAD Architecture 2009\Sample\CS.NET\

AecHardwiredStylesMgd
Good luck.
Message 3 of 8
Anonymous
in reply to: Anonymous

Look this example

#region CreateMemberPolyLine


private ObjectId CreateMemberPolyLine(ObjectId Obj)

{

Document doc =

Application.DocumentManager.MdiActiveDocument;

Database db = doc.Database;

Transaction tr =

doc.TransactionManager.StartTransaction();

using (tr)

{

Polyline pline = (Polyline)tr.GetObject(Obj, OpenMode.ForRead);

Member mem = new Member();

mem.SetToStandard(db);

mem.SetBaseCurve(pline, pline.Normal);

tr.AddNewlyCreatedDBObject(mem, true);

tr.Commit();

return mem.Id;

}

}

#endregion

Message 4 of 8
Anonymous
in reply to: Anonymous

Thank you for your help. I was able to use the example to create the Member Style and to put it in the Style dictionary. I can assign the style manually to a beam member in my drawing. When I try to assign the Style to the member programmatically using

{color:#00ffff}MemberStyle{color} style;
{color:#00ffff}Member{color} joist;
...
...
joist.StyleId = style.ObjectId;

I get an exception that says:

{color:#ff0000}Exception has been thrown by the of an invocation. ---> System.MissingMethodException: Method not found: 'Void Autodesk.Aec.DatabaseServices.Entity.set_StyleId(Autodesk.AutoCAD.DatabaseServi ces.ObjectId)'.{color}
Message 5 of 8
Anonymous
in reply to: Anonymous

Thanks for all of the help. I was finally able to attach the MemberStyle to the Member programmatically.
Message 6 of 8
Anonymous
in reply to: Anonymous

leonardlay,
Got any advice for attaching a style to a member programatically?
I have successfully created a member style and successfully drawn a member with the Standard member style,
but I cannot find how to apply the new style to the structural member.
Message 7 of 8
Anonymous
in reply to: Anonymous

Once you create the style, get its ObjectId. Then open the structural member for write in a transaction, set its StyleId property to the id of the style you want, and commit the transaction.

You can also attach the style id as soon as you create the member and before you commit it so you don't have to start another transaction. Edited by: a_atl on Aug 3, 2009 8:00 PM
Message 8 of 8
Anonymous
in reply to: Anonymous

Thanks for the pointers. I already figured it out.
I just had to search for the owner of the StyleId property.
Isn't it funny, you always "see the light" after you have posted!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost