Results 1 to 7 of 7

Thread: getting current values of some objects and retaining them at the end

  1. #1
    100 Club
    Join Date
    2006-12
    Posts
    145
    Login to Give a bone
    0

    Default getting current values of some objects and retaining them at the end

    Hi,
    I'm doing my first big VBA programming and having very meny questions. I want to get values of current Layer, Text style, Linetype, Lineweight and Color then set what I want and then set back these 5 values to what they were at the beginning.
    With Layer, Textstyle and Linetype I can get through like this:

    Code:
        Set BeginningLayer = ThisDrawing.ActiveLayer
        Set BeginningTextStyle = ThisDrawing.ActiveTextStyle
        Set BeginningLinetype = ThisDrawing.ActiveLinetype
    but I can't do same with lineweight and color properties. What are other ways how to do this?



    Also, additional question about making blocks. In block definition I place some polylines and Mtexts. I want to have their properties BYBLOCK but this far I succeed only with Linewight and it looks like this:

    Code:
       pl.Lineweight = acLnWtByBlock
        mTextObj.Lineweight = acLnWtByBlock
    How do I set Color and Linetype properties BYBLOCK?

    OK, I got it myself about block:
    in the begining of block definition I place:
    ThisDrawing.ActiveLinetype = ThisDrawing.Linetypes.Item("BYBLOCK")
    this makes every object's linetype BYBLOCK
    And with color for each object I use:
    pl.color = acByBlock
    For some reason VB doesn't offer "color" in the drop-down list after typing "pl." but it offers a drop-down list after typing "=".
    So, I'm done BYBLOCK question and the only unclear is about active lineweight and color properties. Anyway, any thaughts about how it could be done better are welcome!
    Last edited by Ed Jobe; 2009-01-05 at 05:04 PM. Reason: Added Code tags.

  2. #2
    Active Member
    Join Date
    2002-06
    Location
    Portland, OR
    Posts
    83
    Login to Give a bone
    0

    Default Re: getting current values of some objects and retaining them at the end

    I think the easiest way would be to pull these from the active layer...what are the downsides of doing this?

  3. #3
    100 Club
    Join Date
    2006-12
    Posts
    145
    Login to Give a bone
    0

    Default Re: getting current values of some objects and retaining them at the end

    Quote Originally Posted by Ben Jones View Post
    I think the easiest way would be to pull these from the active layer...what are the downsides of doing this?
    What exactly do you mean with "pull these from the active layer"?
    For example, in existing dwg active color is blue, active linetype is Continuous and active lineweight is 0.25 mm. I want to place some objects with all these 3 properties BYLAYER. Because I don't want to specify for each new object that these 3 properties are BYLAYER I'm looking if there is an option to record these properties, set as active BYLAYER and after I'm done to restore Blue, Continuous and 0.25 mm as active properties. Same with active layer and text style.

  4. #4
    Active Member
    Join Date
    2002-06
    Location
    Portland, OR
    Posts
    83
    Login to Give a bone
    0

    Default Re: getting current values of some objects and retaining them at the end

    ah...gotcha...

    How about looking at CECOLOR and CELWEIGHT system variable?

  5. #5
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,420
    Login to Give a bone
    0

    Default Re: getting current values of some objects and retaining them at the end

    ...for that, you will need to use ThisDrawing.GetVariable and ThisDrawing.SetVariable.
    C:> ED WORKING....


    LinkedIn

  6. #6
    100 Club
    Join Date
    2006-12
    Posts
    145
    Login to Give a bone
    0

    Default Re: getting current values of some objects and retaining them at the end

    Thank you guys!
    With combining variables and ThisDrawing.Active... elements I got what I want.
    The code now looks like:
    Code:
    'before processing:
        Set BeginningLineType = ThisDrawing.ActiveLinetype
        SysVarName = "CELWEIGHT"
        BeginningLineWeight = ThisDrawing.GetVariable(SysVarName)
    
    'while processing:
        ThisDrawing.ActiveLinetype = ThisDrawing.Linetypes.Item("BYLAYER")
        SysVarName = "CELWEIGHT"
        ThisDrawing.SetVariable SysVarName , -1
    
    'afterwards:
        ThisDrawing.ActiveLinetype = BeginningLineType
        SysVarName = "CELWEIGHT"
        ThisDrawing.SetVariable SysVarName , BeginningLineWeight
    Btw, what's the way to get CODE tags other than write it manually each time?

  7. #7
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,420
    Login to Give a bone
    0

    Default Re: getting current values of some objects and retaining them at the end

    Click on "Go Advanced" and use the # button.
    C:> ED WORKING....


    LinkedIn

Similar Threads

  1. Replies: 12
    Last Post: 2017-07-20, 08:25 AM
  2. 2012: Re define dynamic block retaining current visability state
    By lesleys in forum Dynamic Blocks - Technical
    Replies: 8
    Last Post: 2012-06-04, 12:06 PM
  3. Objects not retaining texture space settings
    By payre in forum NavisWorks - General
    Replies: 1
    Last Post: 2011-12-08, 07:10 PM
  4. Ability to snap to all objects in a 3D view, not just objects on the current reference plane
    By revit.wishlist1942 in forum Revit Architecture - Wish List
    Replies: 0
    Last Post: 2010-03-12, 06:09 AM
  5. Replies: 4
    Last Post: 2008-11-13, 05:36 AM

Posting Permissions

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