Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Revcloud and Delta routine.

20 REPLIES 20
SOLVED
Reply
Message 1 of 21
Anonymous
4071 Views, 20 Replies

Revcloud and Delta routine.

I'm trying to create a lisp routine where It will create a layer for the delta that is needed and at the same time adds the delta. I get delta revisions often and it takes time to add a new layer and a new delta for each plan. I would like to create a routine that creates the the new layer based on the revision number.

 

For example if I get a revision 2 I would like to have a lisp routine that creates a new layer but asks what number i would like to use, once the new layer gets created the revcloud command would run, I use polylines around my revisions then change them to cloud with the revcloud command. after i pick my polylines to be changed to clouds then it would add a delta block that is in an attribute and it lets me put the number of the revision i want. At the end I would have a new layer, a cloud around my revision and a delta corresponding to the revision number i'm currently working with.

 

I have a routine that creates the new layer, sets it current, and starts the revcloud command where i can pick the objects to change to clouds, after that I'm stuck, I'm not sure how to tell AutoCAD that after the selection is made to start the insert command to insert that delta attribute block. I mean the routine ends after i pick my objects, I tried doint the delta first but i ran into the same issue since my routine ends after AutoCAD ask me to pick a location to put my delta block.

 

I need to figure a way to tell AutoCAD that after something is picked or selected then to continue with the lisp routine without ending it. I atteched an example of what I have for anyone to review. Any help is highly apprecitaed and thanks in advance.

20 REPLIES 20
Message 2 of 21
Kent1Cooper
in reply to: Anonymous


@Anonymous.sosa wrote:

....I tried doin[g] the delta first but i ran into the same issue since my routine ends after AutoCAD ask me to pick a location to put my delta block.

....


In your attached code, the command-prompt responses are not right for the commands.  Try something more like this [untested]:

 

(defun c:DCLO ()
  (command

    "layer" "MAKE" "REV1" "COLOR" "51" "" ""

    "INSERT" "DT"

    pause ;; for insertion point

    "" "" "" ;; X Y scale factors & rotation [defaults]

    "1" ;; Attribute value [assuming only the one Attribute]

    "REVCLOUD" "ARC" "12" "12" "" pause "NO" ;; to select the Object

  ); command

); defun

 

[I shortened the Layer command by using the Make option, which also sets the Layer current, eliminating the need for the Set option, and which also therefore makes it the default for assigning the color so you don't have to spell out the Layer name again to do that.  It won't be troubled if the Layer already exists, any more than it would be with the New option.]

 

Presumably, so that one routine could serve for all revisions and you wouldn't need to make separate ones for every possible revision number, the complete routine would either first ask the User for a revision number or would be a function rather than a command [i.e. without the c: beginning] with the revision number as an argument, and you would then use that number to both construct the Layer name and fill in the Attribute.

 

Since you didn't post the Revcloud-before-Insert variety, I couldn't say what's causing that not to work, but very likely it's the same kinds of things.  You just need to exactly replicate the way you would do it at the Command: line, with the little syntactical niceties like using pause for User input, and "" for Enter, and putting command names and textual input in quotes, etc.

Kent Cooper, AIA
Message 3 of 21
stevesfr
in reply to: Kent1Cooper

How to allow for user input for revision number ? instead of default shown as 1 ??
Message 4 of 21
Kycau
in reply to: stevesfr

instead of  "1" you should put pause

 

smth. like this:

(defun c:DCLO ()
  (command
    "layer" "MAKE" "REV1" "COLOR" "51" "" ""
    "INSERT" "DT"
    pause
    "" "" ""
    pause
    "REVCLOUD" "ARC" "12" "12" "" pause "NO"
  )
)
 

 

Message 5 of 21
Kycau
in reply to: Kent1Cooper

I saw through this forum that some sutolisp-profesionals use to write commands like (example):

"_.layer" instead of "layer"

"_.insert" instead of "INSERT"

 

Is this form "_.<command>" really more helpfull ?

Message 6 of 21
Kent1Cooper
in reply to: Kycau


@Kycau wrote:

I saw through this forum that some sutolisp-profesionals use to write commands like (example):

"_.layer" instead of "layer"

"_.insert" instead of "INSERT"

 

Is this form "_.<command>" really more helpfull ?


For a lot of people, yes, and for some it's necessary, so many use that form just to cover everyone.

 

The underscore makes it work in versions of AutoCAD in languages other than English.

 

The period/decimal forces it to use the native AutoCAD command, which prevents problems caused by redefined commands.  For example, the Architectural Desktop overlay program we use here undefines the Layer command and makes its own enhanced version of it, and if I use "layer" or "_layer" inside a (command) function, it gives me an error message that it doesn't know that command.  Lisp-redefined [or VLX or whatever] commands such as what ArchDesktop uses are recognized at the Command: prompt when typed in, or in a Script or Macro, but not within a (command) function, which will recognize only AutoCAD's defined commands, and in our situation Layer has been undefined.  We need to include the period so it will dig down to the native AutoCAD command definition.

 

The underscore and period can be in the other order without affecting anything.

Kent Cooper, AIA
Message 7 of 21
Kent1Cooper
in reply to: stevesfr


@stevesfr wrote:
How to allow for user input for revision number ? instead of default shown as 1 ??

I built in the 1 only because in your initial code the Layer name had that built in.  Rather than use a pause at the point of Attribute input as Kycau suggested, I would ask for the revision number from the User at the beginning, and it can be used [as I suggested above] in both constructing the Layer name and in filling in the Attribute.  For instance:

 

(defun c:DCLO ()

  (setq RevNo (getstring "\nRevision Number: "))
  (command

    "layer" "MAKE" (strcat "REV" RevNo) "COLOR" "51" "" ""

    "INSERT" "DT" pause "" "" ""

    RevNo ;; Attribute value [assuming only the one Attribute]

    "REVCLOUD" "ARC" "12" "12" "" pause "NO"

  ); command

); defun

 

You can get a lot more sophisticated if you want.  It could be made to ask for an integer rather than a string, to ensure the User doesn't give it something inappropriate like a letter or word, and then convert the integer to a text string that it will need to be for the Layer name and Attribute.  That approach can also be done in a way that prevents their entering 0 or a negative number.  Or it could still ask for a string, and could check whether the User's input is a string that represents and integer, and ask again if it isn't.  It could even be made to store the Revision number, and offer the current one as a default [assuming you may need to mark more than one area with the same Revision] with an option to move up to the next one.  And other things....

Kent Cooper, AIA
Message 8 of 21
Anonymous
in reply to: Kent1Cooper

I like your routine since it creates the layer based on the input received from the user after it wask for the revision number. For some reason after I pick the location for the delta the attribute gets filled out with the revcloud command then it wants to create an arc and that's where the command ends. So I have a delta that instead of a number says revcloud. I'll mess with it and figure it out but thank you very much for your help and everybody else that contributed, all of you guys do a great job, Thank you!

Message 9 of 21
Kent1Cooper
in reply to: Anonymous


@Anonymous.sosa wrote:

.... For some reason after I pick the location for the delta the attribute gets filled out with the revcloud command then it wants to create an arc and that's where the command ends. So I have a delta that instead of a number says revcloud. ....


Is there perhaps some option in defining a Block, in later versions than mine, that requires a different number of inputs when Inserting it?  It sounds like it must be using up the RevNo variable to answer a prompt that I don't have, before it gets to asking for the Attribute value.  If that's the issue, do it manually and see exactly what the prompts are, and supply an additional answer as needed [possibly just one more ""], and the Attribute input should arrive at the right prompt.  Type the command name in with a preceding hyphen -INSERT to get the command-line rather than the dialog-box version of it.

Kent Cooper, AIA
Message 10 of 21
Anonymous
in reply to: Kent1Cooper

It ask to confirm the attribute entry. below is an example of what it does.

 

Command: clo

Revision Number: 8 layer Current layer:  "REV5" Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Fre eze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: MAKE Enter name for new layer (becomes the current layer) <REV5>: REV8 Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Fre eze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: COLOR New color [Truecolor/COlorbook] : 51 Enter name list of layer(s) for color 51 <REV8>: Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Fre eze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: Command: INSERT Enter block name or [?] <DT>: DT Units: Inches   Conversion:     0'-1" Specify insertion point or [Basepoint/Scale/X/Y/Z/Rotate]: Enter X scale factor, specify opposite corner, or [Corner/XYZ] <1>: Enter Y scale factor <use X scale factor>: Specify rotation angle <0>: Enter attribute values 2 <2>: 8 Verify attribute values 2 <8>: REVCLOUD Command: ARC Specify start point of arc or [Center]: 12 Point or option keyword required. ; error: Function cancelled Specify start point of arc or [Center]: Specify second point of arc or [Center/End]: Specify end point of arc:

 

It's kinda hard to follow but I higlithed the area where it messes up.

Message 11 of 21
Kent1Cooper
in reply to: Anonymous


@Anonymous.sosa wrote:

It ask to confirm the attribute entry. below is an example of what it does.

 

Command: clo

Revision Number: 8 .... Enter attribute values 2 <2>: 8 Verify attribute values 2 <8>: REVCLOUD ....


Okay, that's not a my-old-version-is-different problem.  There's a "Verify" option in defining an Attribute, which I haven't ever used [I very rarely use Attributes at all].  I would guess that if you go into the DT Block and replace that Attribute definition with one without the Verify option on, it should solve the problem without needing to change the Insert prompt answers, because it should no longer be asking for that verification.

Kent Cooper, AIA
Message 12 of 21
stevesfr
in reply to: Kycau

wishful thinking, but no attribute ?
Message 13 of 21
stevesfr
in reply to: Kent1Cooper

Well, the dclo above doesn't work, it doesn't introduce the revno for the attribute ?
Message 14 of 21
Kent1Cooper
in reply to: stevesfr


@stevesfr wrote:
Well, the dclo above doesn't work, it doesn't introduce the revno for the attribute ?

As I understand the OP's command-line report, it does introduce it [the first orange 8], but since the Attribute is apparently defined with the Verify option turned on, the Insert command asks for verification of the Attribute value, which I hadn't anticipated, and the verification prompt is answered by the Revcloud command name.  See my suggestion in Message 11, but it should also be solvable by adding another "" at the end of the Insert command for the verification.

Kent Cooper, AIA
Message 15 of 21
Anonymous
in reply to: Kent1Cooper

That worked! Everything is working fine now. Thanks for your help and great job! Smiley Happy

Message 16 of 21
nadiakBMNJ6
in reply to: Kent1Cooper

Hi.

I followed the lisp and it works except it does not change the attribute in my delta block. 

is there a line missing?

Sorry I am brand new to lisp routines and such.

 

Thanks.

Message 17 of 21
isosa9APBT
in reply to: nadiakBMNJ6

I think your issue might be with your delta block. Here is the current routine that works for me

 

(defun c:CLO ()
(setq RevNo (getstring "\nRevision Number: "))
(command
"layer" "N" "M-DELTA" "COLOR" "red" "M-DELTA" "set" "M-DELTA" "" ""
"INSERT" "DT" pause "" "" ""
RevNo ;; Attribute value [assuming only the one Attribute]
"layer" "MAKE" (strcat "REV" RevNo) "COLOR" "red" "" "ps" "Black and white" "" ""
"REVCLOUD" "ARC" "8" "8" "" pause "NO"
); command
); defun

 

I'm attaching my DT block so you can use.  

Message 18 of 21
isosa9APBT
in reply to: nadiakBMNJ6

Also make sure your "Support File Search Path" is linked to the folder where you have the DT block.

Message 19 of 21
nadiakBMNJ6
in reply to: isosa9APBT

Thank you,

The issue was that my DT drawing had delta as a block. Once brought in thru the lisp command it made it a block within a block and it did not want to update. Exploding a block within DT drawing and reloading the lisp fixed it. 

Thanks.

Message 20 of 21
isosa9APBT
in reply to: nadiakBMNJ6

You can set autocad to not insert it as a block. That way you don't have to deal with the whole exploding it and reloading it. But I'm glad you made it work for you.

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

Post to forums  

Autodesk Design & Make Report

”Boost