Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Change Feature Line Style in LISP

13 REPLIES 13
SOLVED
Reply
Message 1 of 14
Anonymous
9189 Views, 13 Replies

Change Feature Line Style in LISP

Anonymous
Not applicable

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 

0 Likes

Change Feature Line Style in LISP

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 

13 REPLIES 13
Message 2 of 14
Anonymous
in reply to: Anonymous

Anonymous
Not applicable

I don't see 'Style' is exposed for AeccLandFeatureLine COM object.

Without digging it further, I doubt we can access the style.

 

Thanks,

 

0 Likes

I don't see 'Style' is exposed for AeccLandFeatureLine COM object.

Without digging it further, I doubt we can access the style.

 

Thanks,

 

Message 3 of 14
Anonymous
in reply to: Anonymous

Anonymous
Not applicable
How about a "simple" .NET routine that could be called by LISP? I have used a couple of those types of routines for other tasks.

Dave
0 Likes

How about a "simple" .NET routine that could be called by LISP? I have used a couple of those types of routines for other tasks.

Dave
Message 4 of 14
Anonymous
in reply to: Anonymous

Anonymous
Not applicable

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

0 Likes

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

Message 5 of 14
Anonymous
in reply to: Anonymous

Anonymous
Not applicable

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 

0 Likes

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 

Message 6 of 14
Anonymous
in reply to: Anonymous

Anonymous
Not applicable

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

0 Likes

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

Message 7 of 14
Jeff_M
in reply to: Anonymous

Jeff_M
Consultant
Consultant

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_M, also a frequent Swamper
EESignature

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_M, also a frequent Swamper
EESignature
Message 8 of 14
Anonymous
in reply to: Jeff_M

Anonymous
Not applicable

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.

 

References.jpg

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

 

 

 

0 Likes

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.

 

References.jpg

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

 

 

 

Message 9 of 14
Jeff_M
in reply to: Anonymous

Jeff_M
Consultant
Consultant
Accepted solution

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_M, also a frequent Swamper
EESignature

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_M, also a frequent Swamper
EESignature
Message 10 of 14
Anonymous
in reply to: Jeff_M

Anonymous
Not applicable

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

0 Likes

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

Message 11 of 14
Anonymous
in reply to: Anonymous

Anonymous
Not applicable

Dave -

 

Using .NET its just one line of code to change FeatureLine style 🙂

 

Check this -

 

http://adndevblog.typepad.com/infrastructure/2013/11/civil-3d-featureline-labeling-and-style-changin...

 

Cheers,

Partha

0 Likes

Dave -

 

Using .NET its just one line of code to change FeatureLine style 🙂

 

Check this -

 

http://adndevblog.typepad.com/infrastructure/2013/11/civil-3d-featureline-labeling-and-style-changin...

 

Cheers,

Partha

Message 12 of 14
Anonymous
in reply to: Anonymous

Anonymous
Not applicable

Thank you, Partha.  I expect I will be playing more with .NET.  I will be adding this site you referenced to my favorites.

 

Dave 

0 Likes

Thank you, Partha.  I expect I will be playing more with .NET.  I will be adding this site you referenced to my favorites.

 

Dave 

Message 13 of 14
Anonymous
in reply to: Anonymous

Anonymous
Not applicable

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

0 Likes

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

Message 14 of 14
Anonymous
in reply to: Anonymous

Anonymous
Not applicable

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

0 Likes

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.

Post to forums  

Rail Community


Autodesk Design & Make Report