See the top rated post in this thread. Click here

Results 1 to 10 of 28

Thread: Assigning Layer +Line/Curve Style with .net API

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    I could stop if I wanted to
    Join Date
    2015-05
    Location
    West Des Moines
    Posts
    293
    Login to Give a bone
    0

    Default Assigning Layer +Line/Curve Style with .net API

    Hello all,

    I am looking for a .net API routine that can set the layer and line or curve style after selecting multiple line/curve dimensions. I searched for this via LISP, but from what I gathered LISP cannot do this (or at least it would be rather hard to do so) and I believe .net can accomplish this.

    Background: I do a lot of Plat based drafting which involves dimensioning lots, plat boundaries, easements, etc, and as I work through the drawing and dimensioning them I have to make sure I assign the proper layer, and line/curve styles to go with everything. This typically involves creating the dimensions, updating the line/curve style for each type of dimension so they look good for the current drawing setup (the baseline styles are embedded in the template), and then matching properties. Sometimes match properties doesn't work though for reasons unknown to me and I have to manually update the settings. I would like to be able to run a command to do so instead of manually having to scroll through all my layers/styles and it'd be nice for when I notice I miss one I could grab it, run the command, and move on. There are mice with extra side buttons you can get (typically for gaming) that I'm thinking it would be really smooth for with this as I could assign commands to those buttons.

    I have no experience with API coding (and only light LISP knowledge) so unfortunately I kind of need to be spoon fed here. If I get one routine for the line style I can probably/maybe figure out how to convert it to edit the curve style if it's rather simple (IE: replace the code line that specifies line to curve?) and duplicate it for every type of layer and line/curve style.

    A short and sweet version

    -Sets the layer to layer X
    -Sets Line or Curve label style to Y

    Thanks for any and all help!

    Edit: After thinking about it I somewhat rescind/alter my previous request. Rather having a command that runs the single segment label command (_AeccAddSegmentLabel) while setting the layer and using a particular line or curve style would be much more ideal.

    Thanks again.
    Last edited by Varlth; 2015-09-21 at 04:22 PM.

  2. #2
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    8,483
    Login to Give a bone
    0

    Default Re: Assigning Layer +Line/Curve Style with .net API

    It appears you are using a vertical (probably Civil 3D) to AutoCAD. In the Drawing Settings, which can be found by a right-click on the drawing name on the Settings tab of the ToolSpace palette, there is a tab labeled Object Layers. This may do what you are wanting to do.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  3. #3
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,536
    Login to Give a bone
    0

    Default Re: Assigning Layer +Line/Curve Style with .net API

    Quote Originally Posted by Opie View Post
    ... This may do what you are wanting to do.
    Yes; it is my understanding, and I could be mistaken, that the OP wants a LISP routine to [implicitly] store the current settings (Object Layer, and Default Style), set the new settings, allow the Objects to be placed accordingly, and then restore same - just as we would with say Dimensions, or MLeaders, etc.

    Do you happen to already have something in your toolbox for such? If not, I can help out after some project submittals.

    Cheers
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3620, Core i7-7700K 4.2GHz, 64GB RAM, Samsung 970 Pro M.2, 8GB NVIDIA Quadro P4000

  4. #4
    I could stop if I wanted to
    Join Date
    2015-05
    Location
    West Des Moines
    Posts
    293
    Login to Give a bone
    0

    Default Re: Assigning Layer +Line/Curve Style with .net API

    Quote Originally Posted by Opie View Post
    It appears you are using a vertical (probably Civil 3D) to AutoCAD. In the Drawing Settings, which can be found by a right-click on the drawing name on the Settings tab of the ToolSpace palette, there is a tab labeled Object Layers. This may do what you are wanting to do.
    Hi Opie, this does indeed look like an area you can change the default values. The question I have is how do I translate that into either a LISP or dot net code to do it automatically? I thought LISP couldn't handle this type of stuff, but maybe I'm wrong?

    We have four different label styles

    Distance Only
    Bearing + Distance
    Bearing + Distance (stacked)
    Curve Labels

    We then assign them to their respective layer. These bearings/distances are used for lot lines, plat boundaries, and easements so the end goal is to be able to run a command, say ED (Easement- Distance only), and start clicking away at all the easement lines and it will assign the label to the easement layer, and use the easement distance style. Then I may need to do the boundary so I do something like BBDS (Boundary Bearing Distance Stacked) and it sets it to the Boundary layer, and uses the Boundary Bearing/Distance stacked label style. I just hate having to go in and manually update the current label style and layer when I'm dimensioning different things, and on top of that it's easy to miss layers so removing that error is preferred. I prefer automation for this type of stuff when I can.

    Quote Originally Posted by BlackBox View Post
    Yes; it is my understanding, and I could be mistaken, that the OP wants a LISP routine to [implicitly] store the current settings (Object Layer, and Default Style), set the new settings, allow the Objects to be placed accordingly, and then restore same - just as we would with say Dimensions, or MLeaders, etc.

    Do you happen to already have something in your toolbox for such? If not, I can help out after some project submittals.

    Cheers
    Hi Blackbox,

    I believe you're wondering if I have something like this?

    Code:
    (DEFUN C:EAD()
    	(setq cancel *error*)
    	(setq *error* trapdim)
    	(setq oldlayer (getvar "clayer"))
    	(initget "E P")
    	(setq GET1 (getkword "[Existing/Proposed] <Proposed>"))
    	(COND
    		((= GET1 "E")	(COMMAND "-LAYER" "MAKE" "SE-EASE-TXT" "COLOR" "7" "" ""))
    		(T(COMMAND "-LAYER" "MAKE" "SP-EASE-TXT" "COLOR" "2" "" ""))
    	)
    	(COMMAND "DIMALIGNED" "nea" PAUSE "per")
    	(setvar "clayer" oldlayer)
       (princ)
    )
    I use this one for easement dimensions. If LISP can tackle this that's great, I was just under the impression it couldn't. I know the command for adding a single segment is "AeccAddSegmentLabel", but I didn't know how to go further from there with telling it to use certain styles.

    Thanks!
    Last edited by Varlth; 2015-09-23 at 02:58 PM.

  5. #5
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,536
    Login to Give a bone
    0

    Default Re: Assigning Layer +Line/Curve Style with .net API

    You're partially correct; vanilla AutoLISP cannot do this in the sense that it stores some variables, changes them, does something useful, and then restores same (i.e., the Dimension, MLeader reference above). Where you are (or have been led to be) mistaken, is that Visual LISP (ActiveX COM) can do this, but requires some additional overhead to access Civil 3D's COM-exposed settings, etc. required to accomplish what you're asking for.

    To the best of my knowledge, this can all be done in LISP, it's just a matter of who's going to code it first (if it hasn't been coded already; hence my inquiry of Opie's [code] toolbox Haha), and how slow does it perform, given .NET API is often exponentially faster.

    ... One way, or another... More to follow.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3620, Core i7-7700K 4.2GHz, 64GB RAM, Samsung 970 Pro M.2, 8GB NVIDIA Quadro P4000

  6. #6
    I could stop if I wanted to
    Join Date
    2015-05
    Location
    West Des Moines
    Posts
    293
    Login to Give a bone
    0

    Default Re: Assigning Layer +Line/Curve Style with .net API

    Ok I see.

    I try to scour the internet a bit before asking for stuff (So glad google became popular as I grew up because the old days sound awful ), but of course that doesn't mean it's not hiding somewhere. I did find a handful of bearing/distance routines awhile ago, but they all utilize mtext, and are not dynamic which I felt was too much of a problem.

    Whatever you can bring to the table would be greatly appreciated.

  7. #7
    I could stop if I wanted to
    Join Date
    2015-05
    Location
    West Des Moines
    Posts
    293
    Login to Give a bone
    0

    Default Re: Assigning Layer +Line/Curve Style with .net API

    Just wanted to report back in like I said I would. Looks like it's working just as advertised now. Got the template sorted out, and going forward on future drawings this will be easy to use. I use 2016 and it works fine for me so I assume other versions shouldn't have any issue.

    Thanks again Blackbox, and thanks Opie for pointing him in the right direction!

  8. #8
    I could stop if I wanted to
    Join Date
    2015-05
    Location
    West Des Moines
    Posts
    293
    Login to Give a bone
    0

    Default Re: Assigning Layer +Line/Curve Style with .net API

    Hm...

    Some mediocre news.

    The routine works fine for the most part, but if it's used on a parcel line it grabs the parcel's layer instead of setting the layer defined in the routine. I noticed this on the segmentS command when I played with it, but now see it's happening whenever you use the command on a parcel segment.

    Any ideas on this? Normally I would think to add some sort of set layer function before the command is run, but I have the layer set to SP-PL anyways and it uses the O-PRCL layer regardless because that's the layer the lot line is on.

    Thanks

    edit: Also, I don't know if this matters much or not, but since this is being solved by lisp we could probably move this to the appropriate forum.

Similar Threads

  1. Replies: 3
    Last Post: 2012-12-19, 03:00 PM
  2. Custom Line Style Manager to Simplify Line Style Creation
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2008-01-09, 09:21 PM
  3. Assigning Elevation to a Layer
    By ljupadhyay in forum ACA General
    Replies: 6
    Last Post: 2007-04-24, 07:28 PM
  4. Assigning Elevation to a Layer
    By ljupadhyay in forum ACA Wish List
    Replies: 1
    Last Post: 2007-04-24, 05:03 PM
  5. assigning layer key to new all style?
    By vanderloo5 in forum ACA General
    Replies: 0
    Last Post: 2005-06-28, 03:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •