This has got to be something simple, but I can't get my head around it. I want to take a feature line that has been created by the "stepped offset" command and change its style, in LISP, of course. I have the entity name and have dumped the object, but the style of the FL is not one of them. It shows up in the properties box, but how do I get to it to change it??
Dave
Solved! Go to Solution.
This has got to be something simple, but I can't get my head around it. I want to take a feature line that has been created by the "stepped offset" command and change its style, in LISP, of course. I have the entity name and have dumped the object, but the style of the FL is not one of them. It shows up in the properties box, but how do I get to it to change it??
Dave
Solved! Go to Solution.
Solved by Jeff_M. Go to Solution.
I don't see 'Style' is exposed for AeccLandFeatureLine COM object.
Without digging it further, I doubt we can access the style.
Thanks,
I don't see 'Style' is exposed for AeccLandFeatureLine COM object.
Without digging it further, I doubt we can access the style.
Thanks,
Hi Dave -
Using .NET API you should be able to do this.
Check this -
FeatureLine.StyleName -> Gets or sets the Featureline's style name.
Hope this helps.
Thanks,
Partha Sarkar
Autodesk
Hi Dave -
Using .NET API you should be able to do this.
Check this -
FeatureLine.StyleName -> Gets or sets the Featureline's style name.
Hope this helps.
Thanks,
Partha Sarkar
Autodesk
Partha, thank you. Yes I tracked this down yesterday also. Now I am trying to get it working. I have the Feature Line object and I think I need to get the StyleId to get to the StyleName property. I am working in C#, but I am an extreme novice. Any help would be appreciated.
Dave
Partha, thank you. Yes I tracked this down yesterday also. Now I am trying to get it working. I have the Feature Line object and I think I need to get the StyleId to get to the StyleName property. I am working in C#, but I am an extreme novice. Any help would be appreciated.
Dave
Partha, (or anyone), my ignorance of C# will show below. I am trying to change the style of a feature line. O have a LSIP routine that will call this C# routine. The inputs are the Feature Line Object Name and the Style to change it to. I have not figured out the correct program lines. Here is what I have. Any help would be arrpeciated.
Here is the LISP code to call the C# routine.
(defun C:ChangeStyle () (Setq FLLine (car (entsel "\nSlect Featrue Line to change style: "))) (setq FLObject (vlax-ename->vla-object FLLine)) (setq newstyle "Curb") (FLStyleSetLisp FLObject newstyle) )
And here is the C# code that I have so far that obviously does not work.
namespace FLStyleOverride { public class FLStyleOverride { [LispFunction("FLStyleSetLisp")] public ResultBuffer cfunctionFLStyleSet(ResultBuffer rbfArgs) { try { Database db = Application.DocumentManager.MdiActiveDocument.Database; using (Transaction tr = db.TransactionManager.StartTransaction()) { //Get the arguments passed in... Array arInputArgs = null; arInputArgs = rbfArgs.AsArray(); ObjectId objId = (ObjectId)((TypedValue)arInputArgs.GetValue(0)).Value; String Newstyle = (String) ((TypedValue)arInputArgs.GetValue(1)).Value; Object NewStyleId = objId.GetObject(OpenMode.ForWrite); String StyleName = Newstyle; ResultBuffer rbfResult = default(ResultBuffer); rbfResult = new ResultBuffer(new TypedValue(Convert.ToInt32(5005), "ProbableSuccess")); tr.Commit(); return rbfResult; } } catch { ResultBuffer rbfBadResult = new ResultBuffer(new TypedValue((short)LispDataType.Nil)); //ResultBuffer rbfBadResult = String Newstyle; return rbfBadResult; } } } }
Dave
Partha, (or anyone), my ignorance of C# will show below. I am trying to change the style of a feature line. O have a LSIP routine that will call this C# routine. The inputs are the Feature Line Object Name and the Style to change it to. I have not figured out the correct program lines. Here is what I have. Any help would be arrpeciated.
Here is the LISP code to call the C# routine.
(defun C:ChangeStyle () (Setq FLLine (car (entsel "\nSlect Featrue Line to change style: "))) (setq FLObject (vlax-ename->vla-object FLLine)) (setq newstyle "Curb") (FLStyleSetLisp FLObject newstyle) )
And here is the C# code that I have so far that obviously does not work.
namespace FLStyleOverride { public class FLStyleOverride { [LispFunction("FLStyleSetLisp")] public ResultBuffer cfunctionFLStyleSet(ResultBuffer rbfArgs) { try { Database db = Application.DocumentManager.MdiActiveDocument.Database; using (Transaction tr = db.TransactionManager.StartTransaction()) { //Get the arguments passed in... Array arInputArgs = null; arInputArgs = rbfArgs.AsArray(); ObjectId objId = (ObjectId)((TypedValue)arInputArgs.GetValue(0)).Value; String Newstyle = (String) ((TypedValue)arInputArgs.GetValue(1)).Value; Object NewStyleId = objId.GetObject(OpenMode.ForWrite); String StyleName = Newstyle; ResultBuffer rbfResult = default(ResultBuffer); rbfResult = new ResultBuffer(new TypedValue(Convert.ToInt32(5005), "ProbableSuccess")); tr.Commit(); return rbfResult; } } catch { ResultBuffer rbfBadResult = new ResultBuffer(new TypedValue((short)LispDataType.Nil)); //ResultBuffer rbfBadResult = String Newstyle; return rbfBadResult; } } } }
Dave
First week of elk hunting was hot & dusty. Didn't see a thing. Week 2 starts Saturday in Washington with my son, already snowing where we are headed in the morning. Should have better chances.
Now, here's what worked for me. First the lisp, then the c# code:
(defun C:ChangeStyle () (Setq FLLine (car (entsel "\nSlect Featrue Line to change style: "))) (setq FLObject (vlax-ename->vla-object FLLine)) (setq newstyle "Curb") (FLStyleSetLisp (vlax-get FLObject 'Handle) newstyle) )
public class FLStyleOverride { [LispFunction("FLStyleSetLisp")] public ResultBuffer cfunctionFLStyleSet(ResultBuffer rbfArgs) { try { Database db = Application.DocumentManager.MdiActiveDocument.Database; using (Transaction tr = db.TransactionManager.StartTransaction()) { //Get the arguments passed in... Array arInputArgs = null; arInputArgs = rbfArgs.AsArray(); TypedValue tv = (TypedValue)arInputArgs.GetValue(0); ObjectId objId = db.GetObjectId(false, new Handle(Int64.Parse((string)tv.Value, System.Globalization.NumberStyles.AllowHexSpecifier)), 0); string Newstyle = (string)((TypedValue)arInputArgs.GetValue(1)).Value; FeatureLine fl = (FeatureLine)objId.GetObject(OpenMode.ForWrite); fl.StyleName = Newstyle; ResultBuffer rbfResult = default(ResultBuffer); rbfResult = new ResultBuffer(new TypedValue(Convert.ToInt32(5005), "ProbableSuccess")); tr.Commit(); return rbfResult; } } catch { ResultBuffer rbfBadResult = new ResultBuffer(new TypedValue((short)LispDataType.Nil)); //ResultBuffer rbfBadResult = String Newstyle; return rbfBadResult; } } }
First week of elk hunting was hot & dusty. Didn't see a thing. Week 2 starts Saturday in Washington with my son, already snowing where we are headed in the morning. Should have better chances.
Now, here's what worked for me. First the lisp, then the c# code:
(defun C:ChangeStyle () (Setq FLLine (car (entsel "\nSlect Featrue Line to change style: "))) (setq FLObject (vlax-ename->vla-object FLLine)) (setq newstyle "Curb") (FLStyleSetLisp (vlax-get FLObject 'Handle) newstyle) )
public class FLStyleOverride { [LispFunction("FLStyleSetLisp")] public ResultBuffer cfunctionFLStyleSet(ResultBuffer rbfArgs) { try { Database db = Application.DocumentManager.MdiActiveDocument.Database; using (Transaction tr = db.TransactionManager.StartTransaction()) { //Get the arguments passed in... Array arInputArgs = null; arInputArgs = rbfArgs.AsArray(); TypedValue tv = (TypedValue)arInputArgs.GetValue(0); ObjectId objId = db.GetObjectId(false, new Handle(Int64.Parse((string)tv.Value, System.Globalization.NumberStyles.AllowHexSpecifier)), 0); string Newstyle = (string)((TypedValue)arInputArgs.GetValue(1)).Value; FeatureLine fl = (FeatureLine)objId.GetObject(OpenMode.ForWrite); fl.StyleName = Newstyle; ResultBuffer rbfResult = default(ResultBuffer); rbfResult = new ResultBuffer(new TypedValue(Convert.ToInt32(5005), "ProbableSuccess")); tr.Commit(); return rbfResult; } } catch { ResultBuffer rbfBadResult = new ResultBuffer(new TypedValue((short)LispDataType.Nil)); //ResultBuffer rbfBadResult = String Newstyle; return rbfBadResult; } } }
Jeff, better luck this week. I copied the code in and I am getting the same error I was getting earlier. It is not recognizing the FeatureLine Object. I get the following error.
Error 1 The type or namespace name 'FeatureLine' could not be found (are you missing a using directive or an assembly reference?)
I looked at the API reference and it showed the Assembly AeccDbMgd as Version 10.0.1111.0, my version is 9.0.2566.0. I am in C3d 2012. Could this be the problem?? This is the header info.
using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.EditorInput; using Autodesk.AutoCAD.Runtime; using Autodesk.Civil.DatabaseServices; using Autodesk.Civil.DatabaseServices.Styles; using System;
And here are the references.
I plan on retiring in a little less than 2 years. There is no way I will learn enough .NET to make it worth while. I think I will just keep on stumbling along with LISP.
Thanks again for your help.
Dave
Jeff, better luck this week. I copied the code in and I am getting the same error I was getting earlier. It is not recognizing the FeatureLine Object. I get the following error.
Error 1 The type or namespace name 'FeatureLine' could not be found (are you missing a using directive or an assembly reference?)
I looked at the API reference and it showed the Assembly AeccDbMgd as Version 10.0.1111.0, my version is 9.0.2566.0. I am in C3d 2012. Could this be the problem?? This is the header info.
using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.EditorInput; using Autodesk.AutoCAD.Runtime; using Autodesk.Civil.DatabaseServices; using Autodesk.Civil.DatabaseServices.Styles; using System;
And here are the references.
I plan on retiring in a little less than 2 years. There is no way I will learn enough .NET to make it worth while. I think I will just keep on stumbling along with LISP.
Thanks again for your help.
Dave
Make sure your usings are like so for the code I posted:(I should have shown this):
using System;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.Civil.Land.DatabaseServices; //(for 2013+ omit the Land.)
Make sure your usings are like so for the code I posted:(I should have shown this):
using System;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.Civil.Land.DatabaseServices; //(for 2013+ omit the Land.)
Jeff, adding the .Land.DataBaseServices fixed it. Once more, thank you. Also, just another reason I won't be spending a lot of time on .NET. WAY to involved. I guess I'm just too old to learn new tricks.
Dave
Jeff, adding the .Land.DataBaseServices fixed it. Once more, thank you. Also, just another reason I won't be spending a lot of time on .NET. WAY to involved. I guess I'm just too old to learn new tricks.
Dave
Dave -
Using .NET its just one line of code to change FeatureLine style 🙂
Check this -
Cheers,
Partha
Dave -
Using .NET its just one line of code to change FeatureLine style 🙂
Check this -
Cheers,
Partha
Thank you, Partha. I expect I will be playing more with .NET. I will be adding this site you referenced to my favorites.
Dave
Thank you, Partha. I expect I will be playing more with .NET. I will be adding this site you referenced to my favorites.
Dave
hi,
How can i change Line Styles for Detail Lines using API not UI ?
i cant find any function can set the line style for any detail line using API
hi,
How can i change Line Styles for Detail Lines using API not UI ?
i cant find any function can set the line style for any detail line using API
Hi Guys,
I don't have a great understanding of all the coding that you do, but i have an idea that I'm putting out there to see if it is possible.
I would like to have an .dwg file with a bunch of layers sitting in it, and i would like to be able to create a feature line style from each of these layers. The idea is that it would grab the layer name, colour, lineweight, linetype.. Essentially it would just convert a layer into a Feature Line style.
I understand that i could go in and manually create feature line styles and assign the layer to each of them but that is quite time consuming and each of my clients have different drafting and design standards.
Thanks,
Nick
Hi Guys,
I don't have a great understanding of all the coding that you do, but i have an idea that I'm putting out there to see if it is possible.
I would like to have an .dwg file with a bunch of layers sitting in it, and i would like to be able to create a feature line style from each of these layers. The idea is that it would grab the layer name, colour, lineweight, linetype.. Essentially it would just convert a layer into a Feature Line style.
I understand that i could go in and manually create feature line styles and assign the layer to each of them but that is quite time consuming and each of my clients have different drafting and design standards.
Thanks,
Nick
Can't find what you're looking for? Ask the community or share your knowledge.